首页 / PHP / php-Ebay开发人员改进
php-Ebay开发人员改进
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php-Ebay开发人员改进,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含5578字,纯文字阅读大概需要8分钟。
内容图文
![php-Ebay开发人员改进](/upload/InfoBanner/zyjiaocheng/664/eacab291bd4a48a181446913c1675afa.jpg)
经过一番研究和实践,我一直试图获取所有当前有效产品的清单,我设法整理了一个脚本,该脚本将列出我需要的信息(可用库存和sku).现在我遇到的问题是,我必须从网站上手动输入eBay ID,但是我需要自动拉出活动的eBay列表.
这是脚本,它将收集单个产品的信息.
error_reporting(E_ALL);
ini_set('display_errors', '1');
// Load configuration file
$sandbox = false;
$compat_level = 753;
$api_endpoint = $sandbox ? 'https://api.sandbox.ebay.com/ws/api.dll' : 'https://api.ebay.com/ws/api.dll';
$dev_id = $sandbox ? " " : " ";
$app_id = $sandbox ? " " : " ";
$cert_id = $sandbox ? " " : " ";
$auth_token = $sandbox ? " " : " ";
$site_id = 3;
$call_name = 'GetItem';
// Create headers to send with CURL request.
$headers = array
(
'X-EBAY-API-COMPATIBILITY-LEVEL: ' . $compat_level,
'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: ' . $call_name,
'X-EBAY-API-SITEID: ' . $site_id,
);
// Generate XML request
$xml_request = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>
<".$call_name."Request xmlns=\"urn:ebay:apis:eBLBaseComponents\">
<RequesterCredentials>
<eBayAuthToken>" . $auth_token . "</eBayAuthToken>
</RequesterCredentials>
<DetailLevel>ReturnAll</DetailLevel>
<IncludeItemSpecifics>true</IncludeItemSpecifics>
<IncludeWatchCount>true</IncludeWatchCount>
<ItemID>191744777908</ItemID>
</".$call_name."Request>";
// Send request to eBay and load response in $response
$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, $xml_request);
curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($connection);
curl_close($connection);
// Create DOM object and load eBay response
$dom = new DOMDocument();
$dom->loadXML($response);
// Parse data accordingly.
$ack = $dom->getElementsByTagName('Ack')->length > 0 ? $dom->getElementsByTagName('Ack')->item(0)->nodeValue : '';
$eBay_official_time = $dom->getElementsByTagName('Timestamp')->length > 0 ? $dom->getElementsByTagName('Timestamp')->item(0)->nodeValue : '';
//$current_price = $dom->getElementsByTagName('ConvertedCurrentPrice')->length > 0 ? $dom->getElementsByTagName('ConvertedCurrentPrice')->item(0)->nodeValue : '';
//$description = $dom->getElementsByTagName('Description')->length > 0 ? $dom->getElementsByTagName('Description')->item(0)->nodeValue : '';
$itemID = $dom->getElementsByTagName('ItemID')->length > 0 ? $dom->getElementsByTagName('ItemID')->item(0)->nodeValue : '';
$customLabel = $dom->getElementsByTagName('SKU')->length > 0 ? $dom->getElementsByTagName('SKU')->item(0)->nodeValue : '';
$quantity = $dom->getElementsByTagName('Quantity')->length > 0 ? $dom->getElementsByTagName('Quantity')->item(0)->nodeValue : '';
$quantitySold = $dom->getElementsByTagName('QuantitySold')->length > 0 ? $dom->getElementsByTagName('QuantitySold')->item(0)->nodeValue : '';
$quantityAvaliable = $quantity - $quantitySold;
echo "ItemID: ".$itemID."<br>";
echo "sku: ".$customLabel."<br>";
echo "quantity: ".$quantity."quantitySold: ".$quantitySold." quantityAvaliable:".$quantityAvaliable;
我无法确定的是如何从eBay商店中自动获取列表.无需分别输入每个商品ID.
解决方法:
这可以用来获取您在eBay上的所有活动列表.为了解释这一点,基本上是以xml的形式向eBay发出请求. xml请求将告诉eBay您要做什么,然后eBay会以适当的信息进行响应,在这种情况下,您的eBay帐户上的活动列表.您的xml响应存储在var $response中.
error_reporting(E_ALL);
ini_set('display_errors', '1');
// Load configuration file
$sandbox = false;
$compat_level = 753;
$api_endpoint = $sandbox ? 'https://api.sandbox.ebay.com/ws/api.dll' : 'https://api.ebay.com/ws/api.dll';
$dev_id = $sandbox ? "" : "";
$app_id = $sandbox ? "" : "";
$cert_id = $sandbox ? "" : "";
$auth_token = $sandbox ? "" : "";
$site_id = 3;
/**
**Change your call name to the appropriate call you need to make so for example to get list of all active products on your ebay you can use GetMyEbaySelling
**
**/
$call_name = 'GetMyeBaySelling';
// Create headers to send with CURL request.
$headers = array
(
'X-EBAY-API-COMPATIBILITY-LEVEL: ' . $compat_level,
'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: ' . $call_name,
'X-EBAY-API-SITEID: ' . $site_id,
);
/**
**XML request is what your telling ebay you need so this is the basic request to get hold of the active listings
**just to note the listings would be in a var called response.
**/
$xml_request = "<?xml version=\"1.0\" encoding=\"utf-8\"?>
<GetMyeBaySellingRequest xmlns=\"urn:ebay:apis:eBLBaseComponents\">
<RequesterCredentials>
<eBayAuthToken>". $auth_token . "</eBayAuthToken>
</RequesterCredentials>
<Version>753</Version>
<ActiveList>
<Sort>TimeLeft</Sort>
<Pagination>
<EntriesPerPage>100</EntriesPerPage>
<PageNumber>1</PageNumber>
</Pagination>
</ActiveList>
</GetMyeBaySellingRequest>";
// Send request to eBay and load response in $response
$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, $xml_request);
curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($connection);
curl_close($connection);
在这里解释
http://developer.ebay.com/DevZone/XML/docs/Reference/eBay/GetMyeBaySelling.html
内容总结
以上是互联网集市为您收集整理的php-Ebay开发人员改进全部内容,希望文章能够帮你解决php-Ebay开发人员改进所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。