【问题标题】:Etsy PHP API - Delivery OptionsEtsy PHP API - 交付选项
【发布时间】:2016-02-20 20:37:27
【问题描述】:

使用Etsy Listing API,,我返回了与关键字匹配的列表,我可以毫无问题地对它们进行分页。

但是,我只想查找配送至英国的商品。

我尝试使用region URL 参数,但我仍然得到只能运送到美国的物品。

有人可以帮助我了解我需要通过什么才能获得英国可运送的物品吗?

【问题讨论】:

  • 对我来说似乎工作正常here API KEY EXCLUDED
  • @PXgamer 虽然您的 URL 确实有效,但它似乎并没有像预期的那样受到限制。例如,尝试link 和一些项目(发布时第 2 个)Only ships to United States from Alabama, United States.

标签: php api etsy


【解决方案1】:

如果您只想使用可以运送到英国的商品,则必须查看商品的 ShippingInfo。我是这样做的:

$json = file_get_contents("https://openapi.etsy.com/v2/listings/active?keywords=ISBN&region=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);
            }       
        }

    }
}

【讨论】:

    【解决方案2】:

    这是获取运送/交付到“英国”的清单的代码

    <?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) 参数来获取列表的运输详细信息。它获取将在哪个国家/地区交付列表。 希望它对你有用。

    【讨论】:

      猜你喜欢
      • 2012-03-07
      • 1970-01-01
      • 2014-06-11
      • 1970-01-01
      • 1970-01-01
      • 2013-12-15
      • 1970-01-01
      • 2014-11-18
      • 1970-01-01
      相关资源
      最近更新 更多