Question

Using the eBay Trading API AddFixedPrice Item call, I’ve tried the following:

$description = '<p>My Description</p>';

...

<?xml version="1.0" encoding="utf-8"?>
<AddFixedPriceItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">
...
<Description><![CDATA[' . $description . ']]></Description>

And

<Description>' . htmlentities($description) . '</Description>
...
</AddFixedPriceItemRequest>

Neither works. How can I insert html into the description XML fields using the eBay Trading API?

UPDATE: Apparently the main Description field handles html correctly when using htmlentities(). However, the return Description field does not.

Was it helpful?

Solution

Try this it works for me

$new_description = urldecode($new_description);
$new_description = "<![CDATA[" . $new_description . "]]>";
    $feed = <<< EOD
<?xml version="1.0" encoding="utf-8"?>
<ReviseItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<RequesterCredentials>
<eBayAuthToken>$auth_token</eBayAuthToken>
</RequesterCredentials>
<Item ComplexType="ItemType">
<ItemID>$itemid</ItemID>
<DescriptionReviseMode>Replace</DescriptionReviseMode>
<Description>$new_description</Description>
</Item>
<MessageID>1</MessageID>
<WarningLevel>High</WarningLevel>
<Version>837</Version>
</ReviseItemRequest>​
EOD;

$feed = trim($feed);
$site_id = 3;//3 For UK
    $headers = array
        (
        'X-EBAY-API-COMPATIBILITY-LEVEL: 837',
        'X-EBAY-API-DEV-NAME: ' . $dev_id,
        'X-EBAY-API-APP-NAME: ' . $app_id,
        'X-EBAY-API-CERT-NAME: ' . $cert_id,
        'X-EBAY-API-CALL-NAME: ReviseItem',
        'X-EBAY-API-SITEID: ' . $site_id,
    );

    $connection = curl_init();
    curl_setopt($connection, CURLOPT_URL, $api_endpoint);
    curl_setopt($connection, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($connection, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($connection, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($connection, CURLOPT_POST, 1);
    curl_setopt($connection, CURLOPT_POSTFIELDS, $feed);
    curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1);
    $response = curl_exec($connection);
    curl_close($connection);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top