4

Etsy Listing APIを使用すると、キーワードに一致するリストが返され、問題なくページネーションできます。

ただし、英国に配送される商品のみを検索したいと考えています。

URL パラメーターを使用しようとしましたregionが、米国にしか配送できない商品がまだ届きます。

英国で発送可能な商品を受け取るために何を渡す必要があるかを理解するのを手伝ってもらえますか?

4

2 に答える 2

2

英国に発送できるリストのみを使用する場合は、リストの 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);
            }       
        }

    }
}
于 2016-02-19T12:18:26.717 に答える
1

「United Kingdom」に発送/配達するリストを取得するコードは次のとおりです。

<?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)パラメータを使用して、リストの配送の詳細を取得しました。それは、どの国のリストが配信されるかを取得します。それがあなたのために働くことを願っています。

于 2016-02-20T12:37:27.513 に答える