« Back to Documentation Overview

inlineCss – v1.3

 inlineCss(string apikey, string html, bool strip_css)

Send your HTML content to have the CSS inlined and optionally remove the original styles.

Section
Helper
xml-rpc_inlineCss.php
Parameters
apikey a valid API Key for your user account. Get by visiting your API dashboard
html Your HTML content
strip_css optional - Whether you want the CSS <style> tags stripped from the returned document. Defaults to false.
Returns
string Your HTML content with all CSS inlined, just like if we sent it.

Examples (1)

download example code

[1] xml-rpc_inlineCss.php

  1. <?php
  2. /**
  3. This Example shows how to submit HTML content to have the CSS styles inlined and
  4. optionally removed using XML-RPC.
  5. Note that we are using the PEAR XML-RPC client and recommend others do as well.
  6. **/
  7. require_once 'XML/RPC2/Client.php';
  8. require_once 'inc/config.inc.php';
  9. try {
  10. $client = XML_RPC2_Client::create($apiUrl);
  11.  
  12. $html = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  13. "http://www.w3.org/TR/html4/loose.dtd">
  14. <html lang="en"><head>
  15. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  16. <title>Test</title>
  17. <style>body{font-family:arial;}
  18. #header{width:935px;float:left;background:#fecb66;}
  19. #header_content{width:745px;float:left;padding:0 0 0 20px;}
  20. #header_content a{color:#cc6600;}
  21. #header_content h2{font-size:24px;color:#cc6600;float:left;
  22. width:400px;line-height:1.6em;}
  23. #header_content p.login_info{font-size:14px;color:#333;float:right;width:345px;
  24. text-align:right;line-height:1.6em;padding: 15px 0 0 0;}
  25. #header_content ul{list-style:none;width:745px;float:left;margin:0;padding:0;}
  26. #header_content ul li{float:left;width:165px;text-align:center;
  27. padding:0 10px 0 0;}
  28. #header_content ul li a{width:165px;display:block;background:#fcebcb;
  29. line-height:2em;color:#8c6239;text-decoration:none;}
  30. #header_content ul li a:hover{background:#fff;}
  31. #header_content ul li a.selected{background:#fff;}
  32. #container{width:935px;float:left;background:#fff;}
  33. #content{width:743px;float:left;border:1px solid #e9d4bb;height:300px;
  34. margin:30px 0 0 20px;}
  35. </style>
  36. </head>
  37. <body>
  38. <div id="header">
  39. <div id="header_content">
  40. <h2>MailChimp Signup Form Setup</h2>
  41. <p class="login_info">Logged in as username |
  42. <a href="#">log off</a></p>
  43. <ul>
  44. <li><a class="selected" href="#">overview</a></li>
  45. <li><a href="#">select a list</a></li>
  46. <li><a href="#">edit content</a></li>
  47. <li><a href="#">modify styling</a></li>
  48. </ul>
  49. </div>
  50. </div>
  51. <div id="container"><div id="content">Hello thar!</div></div></body></html>';
  52.  
  53. $result = $client->inlineCss($apikey, $html, true);
  54. echo "SUCCESS! \n";
  55. echo "Here is your HTML with the CSS Styles inlined:\n";
  56. echo $result;
  57. } catch (XML_RPC2_FaultException $e){
  58. echo "ERROR!!!!\n";
  59. echo $e->getFaultCode()." : ".$e->getFaultString()."\n";
  60. }
  61.  
  62.  
  63. ?>
  64.