Search code examples
phpsoapebay-api

Ebay API - How to import HTML into description field?


I'm creating an application which lists items on Ebay, and I've been given an HTML page for each and told to make the description match this html. The HTML page is very basic, and in HTML4 (lots of <font> and <p align='left'> etc)

When I file_get_contents() the html I am wrapping it in CDATA to escape the HTML entities and such. Although when I post it, I'm being kicked back an error about string encoding.

Here is my code,

if(ini_get(allow_url_fopen) == 1){
    $page_layout .= "<![CDATA[";
    $page_layout .= file_get_contents("http://www.example.com/".$template->directory."/template/index.htm");
    $page_layout .= "]]>";

    $page_layout = htmlentities($page_layout);
}else{
    // fopen()
}

This is the error, that my SOAPClient is giving me,

Fatal error: SOAP-ERROR: Encoding: string '&lt;![CDATA[&lt;html&gt; &lt;head&gt; &lt;meta http-equiv=&quot; //etc

I've been reading these pages,

Neither of which give me any real idea's. The only thing that I can think of is rebuilding the HTML pages to be XHTML 1.0 Strict. Which is a little frustrating as I have about 10 of them to do!

Any ideas please?


Update
I have converted one template into XHTML and have managed to post the item, although here is the description as rendered on Ebay sandbox.

= 523) {w = document.body.scrollWidth;} else {w = document.body.offsetWidth;if (window.scrollMaxX !== 0) {w += window.scrollMaxX;}}}if (isNaN(w)) {w = 0;}if ((oCl.bFirefox && oCl.bWin) && (h > 32000)) {h = 32000;}rv[0] += h;rv[1] += w;return rv;};ifr.resizeIt = function(callerId) {var oCl = ifr.browserDetect();var size = ifr.getSize();if (size) {if (!oCl.bSafari) {parent.resizeFrame(size);}ifr.setData(size, callerId);};} 

Solution

  • I have managed to solve this by removing both the CDATA and htmlentities from the markup, and also convert the actual page from HTML4 to updated and valid XHTML.

    It has pulled all my formatting, using an embedded stylesheet, except a background coloured padded div.