Вставка html в описание с помощью торгового API eBay
Используя вызов элемента eBay Trading API AddFixedPrice, я попробовал следующее:
$description = '<p>My Description</p>';
...
<?xml version="1.0" encoding="utf-8"?>
<AddFixedPriceItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">
...
<Description><![CDATA[' . $description . ']]></Description>
И
<Description>' . htmlentities($description) . '</Description>
...
</AddFixedPriceItemRequest>
Ни то, ни другое не работает. Как я могу вставить html в поля XML описания с помощью торгового API eBay?
ОБНОВЛЕНИЕ: По-видимому, основное поле описания правильно обрабатывает html при использовании htmlentities(). Однако поле Описания возврата этого не делает.
2
1 answers
Попробуйте это, это работает для меня
$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);
4
Author: Keyur Padalia, 2014-11-06 12:49:37