« 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.
- <?php
- /**
- This Example shows how to submit HTML content to have the CSS styles inlined and
- optionally removed using XML-RPC.
- Note that we are using the PEAR XML-RPC client and recommend others do as well.
- **/
- require_once 'XML/RPC2/Client.php';
- require_once 'inc/config.inc.php';
- try {
- $html = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
- "http://www.w3.org/TR/html4/loose.dtd">
- <html lang="en"><head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>Test</title>
- <style>body{font-family:arial;}
- #header{width:935px;float:left;background:#fecb66;}
- #header_content{width:745px;float:left;padding:0 0 0 20px;}
- #header_content a{color:#cc6600;}
- #header_content h2{font-size:24px;color:#cc6600;float:left;
- width:400px;line-height:1.6em;}
- #header_content p.login_info{font-size:14px;color:#333;float:right;width:345px;
- text-align:right;line-height:1.6em;padding: 15px 0 0 0;}
- #header_content ul{list-style:none;width:745px;float:left;margin:0;padding:0;}
- #header_content ul li{float:left;width:165px;text-align:center;
- padding:0 10px 0 0;}
- #header_content ul li a{width:165px;display:block;background:#fcebcb;
- line-height:2em;color:#8c6239;text-decoration:none;}
- #header_content ul li a:hover{background:#fff;}
- #header_content ul li a.selected{background:#fff;}
- #container{width:935px;float:left;background:#fff;}
- #content{width:743px;float:left;border:1px solid #e9d4bb;height:300px;
- margin:30px 0 0 20px;}
- </style>
- </head>
- <body>
- <div id="header">
- <div id="header_content">
- <h2>MailChimp Signup Form Setup</h2>
- <p class="login_info">Logged in as username |
- <a href="#">log off</a></p>
- <ul>
- <li><a class="selected" href="#">overview</a></li>
- <li><a href="#">select a list</a></li>
- <li><a href="#">edit content</a></li>
- <li><a href="#">modify styling</a></li>
- </ul>
- </div>
- </div>
- <div id="container"><div id="content">Hello thar!</div></div></body></html>';
- $result = $client->inlineCss($apikey, $html, true);
- } catch (XML_RPC2_FaultException $e){
- }
- ?>
| Section | Helper |
|---|
| Parameters | xml-rpc_inlineCss.php|
|---|---|
| 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