Etsy PHP API Delivery Options

Using the Etsy Listing API, I have lists that match the keyword, and I can’t paginate pages without problems.

However, I want to find only lists that are shipped to the UK.

I tried using the regionURL parameter , but I still get items that can only be delivered to the USA.

Can someone help me understand what I need to pass in order to receive UK shipped goods?

+4
source share
2 answers

If you want to use only lists that can be shipped to the UK, you need to look at the ShippingInfo list. Here is how I did it:

$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);
            }       
        }

    }
}
+1
source

Here is the code to get a listing that sends / delivers to the 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;
?>

I used include = ShippingInfo (destination_country_name) to get the shipping details in the list. He receives information about which country the listing will be sent to. Hope this works for you.

+1
source

Source: https://habr.com/ru/post/1628114/


All Articles