1. Go to this page and download the library: Download cedcommerce/etsy-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cedcommerce / etsy-php example snippets
# it will request /categories/tag1/subtag1/subsubtag1
$api->getSubSubCategory(array(
'params' => array(
'tag' => 'tag1',
'subtag' => 'subtag1',
'subsubtag' => 'subsubtag1'
)));
# it will request /shipping/templates sending the "data" array as the post data
$api->createShippingTemplate(array(
'data' => array(
"title" => "First API Template",
"origin_country_id" => 209,
"destination_country_id" => 209,
"primary_cost" => 10.0,
"secondary_cost" => 10.0
)));
= = new Etsy\EtsyClient($auth['consumer_key'], $auth['consumer_secret']);
$client->authorize($auth['access_token'], $auth['access_token_secret']);
$api = new Etsy\EtsyApi($client);
print_r($api->getUser(array('params' => array('user_id' => '__SELF__'))));
print_r($api->createShippingTemplate(array(
'data' => array(
"title" => "First API Template",
"origin_country_id" => 209,
"destination_country_id" => 209,
"primary_cost" => 10.0,
"secondary_cost" => 10.0
))));
# Upload local files: the item value must be an array with the first value as a string starting with "@":
$listing_image = array(
'params' => array(
'listing_id' => '152326352'
),
'data' => array(
'image' => array('@/path/to/file.jpg;type=image/jpeg')
));
print_r($api->uploadListingImage($listing_image));
$args = array(
'params' => array(
'listing_id' => 654321
),
// A list of associations
'associations' => array(
// Could be a simple association, sending something like: ?ive:1:0/DestinationCountry(name,slug)
'ShippingInfo' => array(
'scope' => 'active',
'limit' => 1,
'offset' => 0,
'select' => array('currency_code', 'primary_cost'),
// The only issue here is that sub-associations couldn't be more than one, I guess.
'associations' => array(
'DestinationCountry' => array(
'select' => array('name', 'slug')
)
)
)
)
);
$result = $this->api->getListing($args);