编程语言
首页 > 编程语言> > 如何使用PHP中的Ebay API更改产品数量

如何使用PHP中的Ebay API更改产品数量

作者:互联网

我想做一件简单的事.我想用PHP改变ebay上现有固定价格商品的数量.这可能吗?我之前问过这个问题并得到回复告诉我要阅读这个或那个.我无法找到任何实际的代码示例.我很乐意看到有人发帖.例如,ebay项目编号123456789的数量为50.我想运行一些PHP代码将其更改为20的数量.我想输入项目编号,新数量以及代码中所需的任何ebay验证数据运行.这就是我所需要的一切.
谢谢

解决方法:

试试这个对我有用

$feed = <<< EOD
<?xml version="1.0" encoding="utf-8"?>
<ReviseItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<RequesterCredentials>
<eBayAuthToken>$eBay->auth_token</eBayAuthToken>
</RequesterCredentials>
<Item ComplexType="ItemType">
<ItemID>$itemid</ItemID>
<Quantity> int </Quantity>
</Item>
<MessageID>1</MessageID>
<WarningLevel>High</WarningLevel>
<Version>$eBay->api_version</Version>
</ReviseItemRequest>​
EOD;

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

        // Send request to eBay and load response in $response
        $connection = curl_init();
        curl_setopt($connection, CURLOPT_URL, $this->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);

标签:ebay,php,xml,ebay-api
来源: https://codeday.me/bug/20190722/1505728.html