使用Etsy清单API,我返回了与关键字匹配的列表,并且我可以对它们进行分页,没有问题。
然而,我只想找到那些提供给英国的上市公司。
我尝试使用region的网址参数,但我仍然得到的项目,只能交付到美国。
有人能帮我理解一下我需要通过什么才能得到英国可运输的物品吗?
发布于 2016-02-19 12:18:26
如果你只想使用可以运往英国的清单,你必须看一下列表中的ShippingInfo。我就是这样做的:
$json = file_get_contents("https://openapi.etsy.com/v2/listings/active?keywords=ISBN®ion=GB&includes=ShippingInfo(destination_country_id)&api_key=");
$listings = json_decode($json, true);
foreach($listings['results'] as $listing) {
if (isset($listing['ShippingInfo'])) {
foreach ($listing['ShippingInfo'] as $shipping) {
if ($shipping['destination_country_id'] == 105) {
//this listing ships to UK
print_r($listing);
}
}
}
}发布于 2016-02-20 12:37:27
以下是船舶/送货到“联合王国”的清单代码
<?php
$apiContent = file_get_contents("https://openapi.etsy.com/v2/listings/active?api_key=YOUR-API-KEY-HERE&includes=ShippingInfo(destination_country_name)");
$contentDecode = json_decode($apiContent, true);
$total=0;
foreach ($contentDecode['results'] as $row) {
if (isset($row['ShippingInfo'])) {
foreach ($row['ShippingInfo'] as $r) {
if ($r['destination_country_name'] == "United Kingdom") {
echo "<pre>";
print_r($row);
$total++;
}
}
}
}
echo $total;
?>我使用includes=ShippingInfo(destination_country_name)参数来获取清单的发送细节。它得到了哪个国家的上市将交付。希望它能对你有用。
https://stackoverflow.com/questions/35315047
复制相似问题