Code Monkey home page Code Monkey logo

etsy-php's Introduction

Etsy PHP SDK Build Status

Based on Etsy Rest API description output, this wrapper provides a simple client with all available methods on Etsy API (thanks to the __call magic PHP method!), validating its arguments on each request (Take a look to https://github.com/inakiabt/etsy-php/blob/master/src/Etsy/methods.json for full list of methods and its arguments).

I'm looking for help

Lately, I couldn't dedicate the time I think this repo deserved, so I'm looking for help!

Requirements

Note: I will be working on remove this dependencies

  • cURL devel:
    • Ubuntu: sudo apt-get install libcurl4-dev
    • Fedora/CentOS: sudo yum install curl-devel
  • OAuth pecl package:
    • sudo pecl install oauth
    • And then add the line extension=oauth.so to your php.ini

Installation

The following recommended installation requires composer. If you are unfamiliar with composer see the composer installation instructions.

Add the following to your composer.json file:

{
  "require": {
    "inakiabt/etsy-php": ">=0.10"
  }
}

Usage

All methods has only one argument, an array with two items (both are optional, depends on the method):

  • params: an array with all required params to build the endpoint url.

    Example: getSubSubCategory: GET /categories/:tag/:subtag/:subsubtag

  # it will request /categories/tag1/subtag1/subsubtag1
  $api->getSubSubCategory(array(
          'params' => array(
                         'tag' => 'tag1',
                         'subtag' => 'subtag1',
                         'subsubtag' => 'subsubtag1'
           )));
  • data: an array with post data required by the method

    Example: createShippingTemplate: POST /shipping/templates

  # 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
           )));

OAuth configuration script

Etsy API uses OAuth 1.0 authentication, so lets setup our credentials.

The script scripts/auth-setup.php will generate an OAuth config file required by the Etsy client to make signed requests. Example:

export ETSY_CONSUMER_KEY=qwertyuiop123456dfghj
export ETSY_CONSUMER_SECRET=qwertyuiop12

php scripts/auth-setup.php /path/to/my-oauth-config-destination.php

It will show an URL you must open, sign in on Etsy and allow the application. Then copy paste the verification code on the terminal. (On Mac OSX, it will open your default browser automatically)

Generated OAuth config file

After all, it should looks like this:

<?php
 return array (
  'consumer_key' => 'df7df6s5fdsf9sdh8gf9jhg98',
  'consumer_secret' => 'sdgd6sd4d',
  'token_secret' => 'a1234567890qwertyu',
  'token' => '3j3j3h33h3g5',
  'access_token' => '8asd8as8gag5sdg4fhg4fjfgj',
  'access_token_secret' => 'f8dgdf6gd5f4s',
);

Initialization

<?php
require('vendor/autoload.php');
$auth = require('/path/to/my-oauth-config-destination.php');

$client = 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__'))));

Examples

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

Asociations

You would be able to fetch associations of given your resources using a simple interface:

    $args = array(
            'params' => array(
                'listing_id' => 654321
            ),
            // A list of associations
            'associations' => array(
                // Could be a simple association, sending something like: ?includes=Images
                'Images',
                // Or a composed one with (all are optional as Etsy API says) "scope", "limit", "offset", "select" and sub-associations ("associations")
                // ?includes=ShippingInfo(currency_code, primary_cost):active: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);

To read more about associations: https://www.etsy.com/developers/documentation/getting_started/resources#section_associations

JSON params

There are some methods that Etsy requires to be a JSON string encoded param (ie: param "variations" for "createListingVariations"). For these cases, those params should be defined like this:

    $args = array(
        'params' => array(
            'listing_id' => 654321
        ),
        'data' => array(
          'variations' => array(
            'json' => json_encode(
                array(
                    array(
                        'property_id' => 200,
                        'value' => "Black"
                    ),
                    array(
                        'property_id' => 200,
                        'value' => "White"
                    )
                )
            )
        )
      )
    );

    $result = $this->api->createListingVariations($args);

Testing

$ vendor/bin/phpunit

Changelog

  • 1.0
    • Init commit, working module.

Author

Iñaki Abete web: http://github.com/inakiabt email: [email protected] twitter: @inakiabt

Contribute

Found a bug? Want to contribute and add a new feature?

Please fork this project and send me a pull request!

License

mobiledevice is licensed under the MIT license:

www.opensource.org/licenses/MIT

etsy-php's People

Contributors

gbryan avatar inakiabt avatar inextor avatar kievins avatar korri avatar kylewiedman avatar ravibarnwal avatar shopifychamp avatar tkthundr avatar tudor2004 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

etsy-php's Issues

Time not accepted in params

Hey,

I am unable to get any time parameters to be accepted within findAllShopReceipts. I have tried a few things and in each case the time parameter is ignored and results from all time are returned. e.g.

$api->findAllShopReceipts(array(
    'params' => array(
        'shop_id' => 'shopid',
        'min_created' => strtotime("-1 days"),  //times not accepted?!
        'limit' => 25,
        'page' => 1
    )))

In the response you can see the time has not been accepted;

shop_id	=>	shopid
min_created	=>	null
max_created	=>	null
min_last_modified	=>	null
max_last_modified	=>	null
limit	=>	25
offset	=>	0
page	=>	1
was_paid	=>	null
was_shipped	=>	null

Does anyone have any ideas?

shipping_template_id validation type shouldn't be int

shipping_template_id shouldn't be int. Because if someone create a shipping template he/she will id larger than 41269799259 and this is not integer this is double. This validation should be string or double.
Thanks.

scripts/auth-setup.php throws EtsyRequestException

Hi there!
I used this script before and it worked just fine but today I'm getting this strange error. Any ideas?
It happens within getAccessToken() of OAuthHelper.

Etsy\EtsyRequestException: [1]: Invalid auth/bad request (got a 411, expected HTTP/1.1 20X or a redirect): Array#012(#012)#012<!DOCTYPE html>#012<html lang=en>#012 <meta charset=utf-8>#012 <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">#012 <title>Error 411 (Length Required)!!1</title>#012 <style>#012 *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}#012 </style>#012 <a href=//www.google.com/><span id=logo aria-label=Google></span></a>#012 <p><b>411.</b> <ins>That’s an error.</ins>#012 <p>POST requests require a <code>Content-length</code> header. <ins>That’s all we know.</ins>

How to set language param for API methods?

How can I set the language parameter for some API methods that do not have the "language" key in theiry method.json definition? For example, the findAllTopCategory supports the language parameter.

findAllListingActive not grabbing the keywords parameter

Hi, I am not sure if I am doing something wrong, but when I run findAllListingActive like this:
$api->findAllListingActive(array('params' => array('offset' => '50', 'page' => '2', 'keywords' => 'shirt')))

All parameters are working except for keywords which return empty in the params array at the end of the response.

The method (https://www.etsy.com/developers/documentation/reference/listing#method_findalllistingactive) takes a keyword parameter as text.

Any idea what might be wrong?

Thanks a lot!

creatingListing passes empty params

When creatingListing the EtsyApi call internally prepareParameters() and return empty $params. Which leads to incorrect request and no params is passed to the request.

Throw exception on restricted relations

Just issued a request and got the following return:

  ["error_messages"]=>
  array(1) {
    [0]=>
    string(35) "Access denied on association Images"
  }

I'm wondering if the API should be detecting this and throwing an exception?

Error when running PHPunit

When attempting to use the locally installed (and super old) phpunit 3.7.5 via running ./vendor/bin/phpunit, I get the following:

$ ./vendor/bin/phpunit
PHP Fatal error:  Uncaught Error: Class 'File_Iterator_Facade' not found in /home/me/etsy-php/vendor/phpunit/phpunit/PHPUnit/Util/Configuration.php:813
Stack trace:
#0 /home/me/etsy-php/vendor/phpunit/phpunit/PHPUnit/Util/Configuration.php(776): PHPUnit_Util_Configuration->getTestSuite(Object(DOMElement), NULL)
#1 /home/me/etsy-php/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php(657): PHPUnit_Util_Configuration->getTestSuiteConfiguration(NULL)
#2 /home/me/etsy-php/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php(138): PHPUnit_TextUI_Command->handleArguments(Array)
#3 /home/me/etsy-php/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php(129): PHPUnit_TextUI_Command->run(Array, true)
#4 /home/me/etsy-php/vendor/phpunit/phpunit/composer/bin/phpunit(42): PHPUnit_TextUI_Command::main()
#5 {main}
  thrown in /home/me/etsy-php/vendor/phpunit/phpunit/PHPUnit/Util/Configuration.php on line 813

When I install phpunit globally via sudo apt install phpunit, I get PHPunit 6.5 and running phpunit shows:

$ phpunit
PHPUnit 6.5.5 by Sebastian Bergmann and contributors.

Time: 21 ms, Memory: 4.00MB

No tests executed!

I think PHPunit needs to be upgraded. PR coming! :)

Error while OAuth process

Hello there,

we are currently getting the following error while authentication process:
Error: Invalid auth/bad request (got a 411, expected HTTP/1.1 20X or a redirect): Array ( ) 411 - Length Required.

We reported this issue to etsy and it seems that they changed something. We got the following information:

Due to recent updates, you will now have to specify the GET method when using Oauth. Here’s an example:
$req_token = $oauth->getRequestToken(“https://openapi.etsy.com/v2/oauth/request_token?scope=email_r%20listings_r“, ‘oob’, “GET”);

$acc_token = $oauth->getAccessToken(“https://openapi.etsy.com/v2/oauth/access_token”, null, $verifier, “GET”);

Would it be possible to add the GET parameter to these two functions? I think everyone should run into this issue at the moment.

Invalid auth/bad request (got a 400, expected HTTP/1.1 20X or a redirect): Array ( ) Expected param 'tracking_code'.

I am getting this error when submit tracking code through ETSY API :
Any help would be greatly appreciated !

Etsy\EtsyRequestException
Invalid auth/bad request (got a 400, expected HTTP/1.1 20X or a redirect): Array
(
)
Expected param 'tracking_code'.Array
(
[http_code] => 400
[content_type] => text/plain;charset=UTF-8
[url] => https://openapi.etsy.com/v2/private/shops/xxxxxx/receipts/169999999/tracking?oauth_consumer_key=xxxxxxxx&oauth_signature_method=HMAC-SHA1&oauth_nonce=-xxxxxxxx&oauth_timestamp=1594779809&oauth_version=1.0&oauth_token=xxxxxxxx&oauth_signature=xxxxxxxx
[header_size] => 955
[request_size] => 403
[filetime] => -1
[ssl_verify_result] => 20
[redirect_count] => 0
[total_time] => 1.063
[namelookup_time] => 1.0E-6
[connect_time] => 0.219
[pretransfer_time] => 0.641
[size_upload] => 0
[size_download] => 31
[speed_download] => 29
[speed_upload] => 0
[download_content_length] => 31
[upload_content_length] => -1
[starttransfer_time] => 1.063
[redirect_time] => 0
[headers_recv] => HTTP/1.1 400 Bad Request
Connection: keep-alive
Content-Length: 31
Server: Apache
Set-Cookie: uaid=xxxxxxxx.; expires=Thu, 15-Jul-2021 02:10:31 GMT; Max-Age=31536000; path=/; domain=.etsy.com; secure
X-CLOUD-TRACE-CONTEXT: 2afb84d81257d72489a613e75de0b6a1/372768447438560266;o=0
X-Etsy-Request-Uuid: xxxxxxxx
X-RateLimit-Limit: 10000
X-RateLimit-Remaining: 9449
X-Error-Detail: Expected param 'tracking_code'.
Cache-Control: private
Set-Cookie: user_prefs=xxxxxxxx.; expires=Thu, 15-Jul-2021 02:10:31 GMT; Max-Age=31536000; path=/; domain=.etsy.com
Content-Type: text/plain;charset=UTF-8
Via: 1.1 google
Accept-Ranges: bytes
Date: Wed, 15 Jul 2020 02:10:31 GMT
Via: 1.1 varnish
X-Served-By: cache-hkg17929-HKG
X-Cache: MISS
X-Cache-Hits: 0
X-Timer: S1594779031.219571,VS0,VE214

)
.........
Caused by: OAuthException
Invalid auth/bad request (got a 400, expected HTTP/1.1 20X or a redirect)

My action code :

$return = $this->api->submitTracking(array(
            'params' => array(
                "shop_id"=> "xxxxx",
	     "receipt_id"=> "16999999",				
               "tracking_code"=>"9400109202020999999999",
                "carrier_name"=> "4px",
            )));
print_r($return);

New Variation Support

Will there be an uodate to support the new way etsy handles variations (now called offerings).

The new variation scheme supports price, qty and sku per offering.

uploadListingImage leads to Exception

Hi there
when using uploadListingImage() I'm getting an Exception: Uploading files using php_streams request engine is not supported in vendor/inakiabt/etsy-php/src/Etsy/EtsyClient.php:52

I'm using it like written in the example:

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

What's wrong or missing?

Etsy API question

Sorry to ask here but my question is probably really simple for you guys.

I am trying to use the updateListing method to revise listing descriptions...

https://www.etsy.com/developers/documentation/reference/listing#method_updatelisting

I went through the OAuth Authentication process successfully and am able to make an authorized request via the API as per the example in the documentation. I am having problems with the updateListing method. I am trying to revise the description but get the following error…

“Invalid auth/bad request (got a 400, expected HTTP/1.1 20X or a redirect)Expected param 'quantity'.Array”

As per the documentation, the quantity is not required (and is actually depreciated for updateListing). When I use the existing quantity to populate ‘quantity’ in the array (commented out), it complains about another field it expects. I’m not sure why I’m getting an error regarding these fields as they are not required. I would not mind using the existing attributes available from my listing to populate these fields but there is a “shipping_template_id” field which I don’t currently have available. I can’t set it to null because it expects a numeric value. When I set it to 0, it says that it’s not a valid shipping template ID. I must be doing something wrong.

Here is my code (I replaced my actual token and token secrets)…

$access_token = "my token";
$access_token_secret = "my secret";

$oauth = new OAuth(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);

$oauth->setToken($access_token, $access_token_secret);

try {

$url = "https://openapi.etsy.com/v2/private/listings";

$params = array('listing_id' => $result->listing_id,
                                 //'quantity' => $result->quantity,
                                //'title' => $result->title,
                                'description' => $new_description);

$oauth->fetch($url, $params, OAUTH_HTTP_METHOD_POST);
$json = $oauth->getLastResponse();
print_r(json_decode($json, true));

}
catch (OAuthException $e) {

echo $e->getMessage();
echo $oauth->getLastResponse();
echo $oauth->getLastResponseInfo();

}

array(string), validation

Your parameter validation incorrectly sees array("string1", "string2", "string3") as valid when it will produce an invalid_signature error (code 403) when sent to Etsy. The array(string) parameter type can only contain a single element to be valid. The earlier example must be array("string1, string2, string3") in order to be accepted by Etsy.

updateInventory() fails with no variations/combinations

Hi guys,

I'm using this SDK for synchronization of the quantity of our products.

Etsy-php version: 0.12.1
PHP version: 5.5.9
OAuth version: 1.2.3

The code that I'm using is the following (sample data):

$argument = [
    'params' => [
        'listing_id' => 486961999,
    ],
    'data' => [
        'products' => [
            'json' => json_encode([
                0 => [
                    'sku' => 'HB_XXX123',
                    'offerings' => [
                        0 => [
                            'price' => '19.90',
                            'quantity' => 999,
                        ],
                    ],
                ],
            ]),
        ],
    ],
];

After calling the updateInventory() method with this argument I get an exception:

Etsy\EtsyRequestException: [1]: Invalid auth/bad request (got a 400, expected HTTP/1.1 20X or a redirect): Array
(
    [products] => [{"sku":"HB_XXX123","offerings":[{"price":"19.90","quantity":999}]}]
)

All combinations of property values must be supplied

So, in my case I do not have any combinations and yet the system requests such.

I suppose the problem is in the $argument that I'm passing to the method.

  1. Is there any way to update the quantity of a non-variation (non-combination) products?
  2. Is there a way to update only quantity, without updating the price?

Any idea @inakiabt ?

Error State is required

When I try to connect to etsy, I get an error:
error_description=state+is+required

It looks like "state" is a required parameter, however couldn't find a way to set it?

Any help would be much appreciated!

Image is not uploading.

I tried to use as you provided in example like:
$method = 'uploadListingImage'; $args = array( 'params' => array( 'listing_id' => 123456 ), 'data' => array( 'image' => array('file.jpg;type=image/jpeg') ) );

I used like:

$taxo = $api->uploadListingImage( array( 'params' => array( 'listing_id' => 509505496, ), 'data' => array( 'image'=> array('15.1.jpg;type=image/jpeg') ) ) );

I got the error message:
'Exception' with message 'Invalid params for method "uploadListingImage": Invalid data param type "image" (15.1.jpg;type=image/jpeg: string): required type "imagefile"

Note: my image path is the same of the script.

Thanks.

submitTracking error 411 Length Required

$api->submitTracking(array('params' => 
			array(
			'shop_id' => $shop,
			'receipt_id' => $receipt,
			'tracking_code' => $code,
			'carrier_name' => $carrier,
			)));

response

Fatal error: Uncaught Etsy\EtsyRequestException: [1]:### Invalid auth/bad request (got a 411, expected HTTP/1.1 20X or a redirect): Array ( ) <title>Error 411 (Length Required)!!1

500 error returned from the api

I am using the following simple data params to be passed into the api. I have the latest updated version.
Request:
( [quantity] => 1 [title] => 10KT White Gold 1.75ctw Amethyst & Diamond Cocktail Ring, 11.44gm. Size: 5.25 [description] => This brightly polished 10KT white gold ring contains one amethyst in the center, surrounded by single cut diamonds, all prong set in a raised basket style setting. A twisted rope design finishes the look, all set atop a five layer shank. [price] => 720 [shipping_template_id] => 41269799259 [state] => draft [category_id] => 2115 [who_made] => someone_else [is_supply] => 1 [when_made] => 1980s [taxonomy_id] => 2115 )

Response:

`Server ErrorArray
(
[http_code] => 500
[content_type] => text/plain;charset=UTF-8
[url] => https://openapi.etsy.com/v2/private/listings?oauth_consumer_key=hladz5fxyi06xfngxf&oauth_signature_method=HMAC-SHA1&oauth_nonce=2187758e68632f0.99729084&oauth_timestamp=1491502642&oauth_version=1.0&oauth_token=e05dfe0c2b1f4f50ba905a&oauth_signature=IpZEOOkCHxfsY%3D
[header_size] => 763
[request_size] => 1027
[filetime] => -1
[ssl_verify_result] => 20
[redirect_count] => 0
[total_time] => 3.25
[namelookup_time] => 0.515
[connect_time] => 0.765
[pretransfer_time] => 1.484
[size_upload] => 597
[size_download] => 12
[speed_download] => 3
[speed_upload] => 183
[download_content_length] => 12
[upload_content_length] => 597
[starttransfer_time] => 3.25
[redirect_time] => 0
[headers_recv] => HTTP/1.1 500 Internal Server Error
Server: Apache
X-Etsy-Request-Uuid: FfmZT-rZNAdZuDOzIJJm41whRY3S
X-RateLimit-Limit: 10000
X-RateLimit-Remaining: 9937
X-Error-Detail: Server Error
Cache-Control: private
Content-Length: 12
Content-Type: text/plain;charset=UTF-8
Date: Thu, 06 Apr 2017 18:17:25 GMT
Connection: close
Set-Cookie: uaid=uaid%3Dn28PRQtcM-ZoOKECFux6kkTfHLBo%26_now%3D1491502645%26_slt%3DplKz3Ugl%26_kid%3D1%26_ver%3D1%26_mac%3DIB5NJVofFAYDlE8J1-BdFb-xwPax_U5UHfaBEPSPtmY.; expires=Mon, 07-May-2018 10:35:45 GMT; Max-Age=34186700; path=/; domain=.etsy.com; secure; HttpOnly
Set-Cookie: user_prefs=0m8gropPnCk8OCEvLLyGVs1-7mNjZACCiGdtpjA6Oq80J0eHZCKWAQA.; expires=Fri, 06-Apr-2018 18:17:25 GMT; Max-Age=31536000; path=/; domain=.etsy.com

)`

OAuth configuration script - missing oauth module?!

Hi everyone,

whenever I try to create my oauth configuration script, it only returns the following error:

Fatal error: Uncaught Error: Class 'OAuth' not found in /░░░/inakiabt/etsy-php/src/Etsy/EtsyClient.php:23
Stack trace:
#0 /░░░/inakiabt/etsy-php/scripts/auth-setup.php(41): Etsy\EtsyClient->__construct('░░░...', '░░░')
#1 {main}
  thrown in /░░░/inakiabt/etsy-php/src/Etsy/EtsyClient.php on line 23

Any ideas what I can do about it? I'm running on a MacOS (mojave) and it seems that the MacOS php is not supporting OAuth. How can I install it?

Cheers,
Leopold

Composer is not pulling the latest version?

I'm using to use composer to grab this, but it's not pulling the recent merges. I tried deleting the folder and having composer re-grab it, but it's still getting the old version.

I don't know if this is an issue with the code base. I don't really understand what's happening.

Issues with updating inventory

Thanks for the amazing library!

I first am creating a listing using the createListing method.

I am then trying to add inventory using the updateInventory method, but am getting errors about invalid param type

Invalid params for method "updateInventory": Invalid data param type "products"

If anyone has a sample of the final structure that I need to have in php to use the updateInventory method, that would be very helpful. This is not working for me.

        $etsy_listing_id = 999999999; //during testing, using a real listing id
        $primary_colors_id = 200;

        $colors = [
            [
                'property_id'   => $primary_colors_id,
                'property_name' => 'Primary color',
                'value_ids'     => [1213],
                'values'        => ['Beige'],
            ],
        ];

        $products =
            [
                [
                    'property_values' => [$colors[0]],
                    'sku'       => 'A-800',
                    'offerings' => [
                        [
                            'price'      => 15.00,
                            'quantity'   => 4,
                            'is_enabled' => 1,
                        ],
                    ],
                ],
            ];

        $data = [
            'params' => [
                'listing_id' => $etsy_listing_id,
            ],
            'data' => [
                'products' => json_encode($products),
                "price_on_property" => [$primary_colors_id],
                "quantity_on_property" => [$primary_colors_id],
                "sku_on_property" => [$primary_colors_id],
            ],
        ];

        $etsy_inventory_items = $this->etsy_api->updateInventory($data);

Thank You

Checking Permission Scopes After Authentication

Hi! I decide to check API permission scope. On this page (https://www.etsy.com/developers/documentation/getting_started/oauth#section_checking_permission_scopes_after_authentication) you can get function to do this.
I add such function after function setDebug in EtsyClient.php

	public function getScopes()
	{
        $data = $this->oauth->fetch($this->base_url . "/oauth/scopes", null, OAUTH_HTTP_METHOD_GET);
        $json = $this->oauth->getLastResponse();
        echo '<pre>';
        print_r(json_decode($json, true));
	}

And run it by such code

$this->auth = new \Etsy\EtsyClient($auth['consumer_key'], $auth['consumer_secret']);
$this->auth->authorize($auth['access_token'], $auth['access_token_secret']);
$result = $this->auth->getScopes(true);

In result I got answer

Array
(
    [count] => 18
    [results] => Array
        (
            [0] => email_r
            [1] => listings_r
            [2] => listings_w
            [3] => listings_d
            [4] => transactions_r
            [5] => transactions_w
            [6] => billing_r
            [7] => profile_r
            [8] => profile_w
            [9] => address_r
            [10] => address_w
            [11] => favorites_rw
            [12] => shops_rw
            [13] => cart_rw
            [14] => recommend_rw
            [15] => feedback_r
            [16] => treasury_r
            [17] => treasury_w
        )

    [params] => 
    [type] => ArrayString
    [pagination] => Array
        (
        )

)

Maybe it will be useful to others.

got a 400, expected HTTP/1.1 20X or a redirect): Array ( ) Expected param 'tracking_code'

I'm facing with the issue when use submitTracking method. I dont know why, because It works well when I get order information.

This is my code:

$request = array('params' => array(
'tracking_code' => $trackingcode,
'carrier_name' => $carriername,
'send_bcc' => false,
'shop_id' => $shopid,
'receipt_id' => $etsyreceipt

				));

$response = $GLOBALS['api']->submitTracking($request);

This is the error:
Fatal error: Uncaught Etsy\EtsyRequestException: [1]: Invalid auth/bad request (got a 400, expected HTTP/1.1 20X or a redirect): Array ( ) Expected param 'tracking_code'.Array ( [http_code] => 400 [content_type] => text/plain;charset=UTF-8 [url] => https://openapi.etsy.com/v2/private/shops/xxxx/receipts/xxxx2/tracking?oauth_consumer_key=xxx&oauth_signature_method=HMAC-SHA1&oauth_nonce=xxxxx&oauth_timestamp=1500688376&oauth_version=1.0&oauth_token=xxxxx&oauth_signature=xxxx [header_size] => 920 [request_size] => 400 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.509848 [namelookup_time] => 0.0124 [connect_time] => 0.01332 [pretransfer_time] => 0.030961 [size_upload] => 0 [size_download] => 31 [speed_download] => 60 [speed_upload] => 0 [download_content_length] => 31 [upload_content_length] => 0 [starttran in public_html/etsy/src/Etsy/EtsyClient.php on line 67

I checked on tracking_code field. It was filled. I believe all require params are already there.

I really appreciate for any help,

Dependencies?

Does this still have the PERL dependencies? I am looking for something I can use on a windows II7 machine running php. Actually the goal is to use JavaScript (jquery) to push values to something like your library, and then have your library do the OAuth nonsense with etsy. Is this sort of what you have mapped out with querystrings?

Thanks

Create Product Listing

Hi,

i Download your code and try to post product on etsy marketplace but i got an error

Fatal error: Uncaught Etsy\EtsyRequestException: [1]: Invalid auth/bad request (got a 400, expected HTTP/1.1 20X or a redirect): Array ( [quantity] => 1 [title] => This is a Second [description] => This is a Second. [price] => 6.99 [state] => active [shipping_template_id] => 41335773035 [shop_section_id] => 18026382 [tags] => Array ( [0] => color ) [who_made] => i_did [is_supply] => [when_made] => 1960s ) Invalid value for boolean.Array ( [http_code] => 400 [content_type] => text/plain;charset=UTF-8 [url] => https://openapi.etsy.com/v2/private/listings?oauth_consumer_key=6pdyciuv2kfmkfj8tvkb1ioa&oauth_signature_method=HMAC-SHA1&oauth_nonce=1114058eb60a5369b65.97527369&oauth_timestamp=1491820709&oauth_version=1.0&oauth_token=6ecb38f3827649a44a1412cc3c8989&oauth_signature=YUf9yFoR3rSILq07FpcaxS%2BDkUI%3D [header_size] => 767 [request_size] => 640 [filetime] => -1 [ssl_verify_result] => 20 [redirect_count] => 0 [tota in D:\xampp\htdocs\etsy-php-master\src\Etsy\EtsyClient.php on line 65

My Code
$client = new Etsy\EtsyClient($auth['consumer_key'], $auth['consumer_secret']);
$client->authorize($auth['access_token'], $auth['access_token_secret']);
$api = new Etsy\EtsyApi($client);
$new_listing = array(
'data' => array(
'quantity' => 1,
'title' => 'This is a Second',
'description' => 'This is a Second.',
'price' => 6.99,
'state' => 'active',
'shipping_template_id'=> 41335773035,
'shop_section_id' => 18026382,
'tags' => array("color"),
'who_made' => 'i_did',
'is_supply' => false,
'when_made' => '1960s',

)

);

$new_listing_response = $api->createListing($new_listing);
echo "

"; print_r($new_listing_response);exit;

if you have any solution please help me.

How to get access token and secret?

Hi,
Install this package in Laravel

public function connect(Request $request)
{
    $callbackUrl = env('APP_URL') . '/etsy/callback';
    $client = new Etsy\EtsyClient(env('ETSY_CONSUMER_KEY'), env('ETSY_CONSUMER_SECRET'));
    $helper = new Etsy\OAuthHelper($client);

    $authorizationUrl = $client->getRequestToken(
        array(
            'callback' => $callbackUrl,
            'scope' => 'transactions_r'
        )
    );

    return redirect($authorizationUrl['login_url']);
}

After connection in callback url I got like this

http://127.0.0.1:8000/etsy/callback?oauth_token=ea1d.....21&oauth_verifier=4c....5c9#_=_

In callback function, I don't know how to get access token and secret

public function callback(Request $request)
{
$client = new Etsy\OAuthHelper(env('ETSY_CONSUMER_KEY'), env('ETSY_CONSUMER_SECRET'));
}
In your document I don't see how to get access token
What is the next step?
Thanks

updateInventory fails with multiple values in price_on_property, quantity_on_property, and sku_on_property

This drove me crazy for a day.

from methods.json on updateInventory these must be changed from;

"price_on_property": "array(int)", "quantity_on_property": "array(int)", "sku_on_property": "array(int)"

to:

"price_on_property": "string", "quantity_on_property": "string", "sku_on_property": "string"

When submitting the request to Etsy, array(int) will only work with one value, but if you need to add another property_id such as array(int, int) it will fail. This was actually crashing my Apache server so it was rather hard to debug. On the Etsy documentation it asks for array(int) but a string will actually work just fine for one propert_id or two property_id's. ie;

$args = array( 'params' => array( 'listing_id' => $product['id_etsy'] ), 'data' => array( 'products' => json_encode( $ListingProducts ), 'price_on_property' => "100,200", 'quantity_on_property' => "100,200" ) );

libcurl4 is a virtual package with many candidates in Mint 17 - only one works

$ sudo apt-get install libcurl4-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package libcurl4-dev is a virtual package provided by:
  libcurl4-openssl-dev 7.35.0-1ubuntu2.3
  libcurl4-nss-dev 7.35.0-1ubuntu2.3
  libcurl4-gnutls-dev 7.35.0-1ubuntu2.3
You should explicitly select one to install.

E: Package 'libcurl4-dev' has no installation candidate

libcurl4-gnutls-dev is the only libcurl4 package I've found to work with every function in this library.

Probleam in creatingListing

Hello, With this sdk , I am trying to connect to etsy shop and do listing with createListing like this :

                       $auth = require(FCPATH.'/credential.php');
	$access_token = '2aa947e452b2b16e671b23b2eb9143';// get from db
	$access_token_secret ='ceb0bb4e8e'; // get from db
	$client = new Etsy\EtsyClient($auth['consumer_key'], $auth['consumer_secret']);
	$client->authorize($auth['access_token'], $auth['access_token_secret']);
	echo '<pre>'; 
	print_r($client);
	echo '</pre>';
	$this->api = new Etsy\EtsyApi($client);
	$args = array(
		'data' => array(
			"quantity" => 123456,
			"title" => "string",
			"description" => "text",
			"price" => 12.3456,
			"materials" => array('wood, plastic'),
			"shipping_template_id" => 123456,
			"shop_section_id" => 123456,
			"image_ids" => array(1), // Multimple?
			"non_taxable" => false,
			"state" => "active",
			"processing_min" => 123456,
			"processing_max" => 123456,
			"category_id" => 123456,
			"taxonomy_id" => 123456,
			"tags" => array('fashion, othertag'),
			"who_made" => "collective",
			"is_supply" => true,
			"when_made" => "2000_2009",
			"recipient" => "men",
			"occasion" => "baptism",
			"style" => array('style1, style2')
		)
	);

	$result = $this->api->createListing($args);
	echo '<pre>'; 
	print_r($result);
	echo '</pre>';
	die;

But it gives me this error:
An uncaught Exception was encountered
Type: Etsy\EtsyRequestException

Message: Invalid auth/bad request (got a 403, expected HTTP/1.1 20X or a redirect): Array ( [quantity] => 123456 [title] => string [description] => text [price] => 12.3456 [materials] => Array ( [0] => wood, plastic ) [shipping_template_id] => 123456 [shop_section_id] => 123456 [image_ids] => Array ( [0] => 1 ) [non_taxable] => 0 [state] => active [processing_min] => 123456 [processing_max] => 123456 [category_id] => 123456 [taxonomy_id] => 123456 [tags] => Array ( [0] => fashion, othertag ) [who_made] => collective [is_supply] => 1 [when_made] => 2000_2009 [recipient] => men [occasion] => baptism [style] => Array ( [0] => style1, style2 ) ) This method requires scope authentication not granted.Array ( [url] => https://openapi.etsy.com/v2/private/listings?oauth_consumer_key=zies3vygeshxe9m8seyxb3qu&oauth_signature_method=HMAC-SHA1&oauth_nonce=18621825675a745530af6442.20859604&oauth_timestamp=1517573424&oauth_version=1.0&oauth_token=2aa947e452b2b16e671b23b2eb9143&oauth_signature=A2MaZ04rQ3qRBBoAviKUJj6uSdE%3D [http_code] => 403 [content_type] => text/plain;charset=UTF-8 [download_content_length] => 54 [size_download] => 54 [size_upload] => 394 ) Array ( [sbs] => POST&https%3A%2F%2Fopenapi.etsy.com%2Fv2%2Fprivate%2Flistings&category_id%3D123456%26description%3Dtext%26image_ids%3D1%26is_supply%3D1%26materials%3Dwood%252C%2520plastic%26non_taxable%3D0%26oauth_consumer_key%3Dzies3vygeshxe9m8seyxb3qu%26oauth_nonce%3D18621825675a745530af6442.20859604%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1517573424%26oauth_token%3D2aa947e452b2b16e671b23b2eb9143%26oauth_version%3D1.0%26occasion%3Dbaptism%26price%3D12.3456%26processing_max%3D123456%26processing_min%3D123456%26quantity%3D123456%26recipient%3Dmen%26shipping_template_id%3D123456%26shop_section_id%3D123456%26state%3Dactive%26style%3Dstyle1%252C%2520style2%26tags%3Dfashion%252C%2520othertag%26taxonomy_id%3D123456%26title%3Dstring%26when_made%3D2000_2009%26who_made%3Dcollective [headers_sent] => Content-Type: application/x-www-form-urlencoded [headers_recv] => HTTP/1.1 403 Forbidden Server: Apache Set-Cookie: uaid=uaid%3Dp3fBn4LRkisO38yEhzqABvQRJ3YL%26_now%3D1517573426%26_slt%3DaXyj4cix%26_kid%3D1%26_ver%3D1%26_mac%3DSv29JtzlzexCmpGB4RNm68Elf-YiBuUNkzrKzDkDBds.; expires=Tue, 05-Mar-2019 04:28:46 GMT; Max-Age=34186700; path=/; domain=.etsy.com; secure; HttpOnly X-Etsy-Request-Uuid: EurMhPOHwFyblnxPzpAcFwIN0105 X-RateLimit-Limit: 10000 X-RateLimit-Remaining: 9998 X-Error-Detail: This method requires scope authentication not granted. Cache-Control: private Set-Cookie: zuaid=uaid%3Dp3fBn4LRkisO38yEhzqABvQRJ3YL%26_now%3D1517573426%26_slt%3DI5Y2TbCA%26_kid%3D1%26_ver%3D1%26_mac%3DzSjDq5vkougXgxnzL2Nu6F1XBzkc3JnTWZy0s4MAmf8.; expires=Sun, 04-Mar-2018 12:10:26 GMT; Max-Age=2592000; path=/; domain=.etsy.com; secure; HttpOnly Set-Cookie: user_prefs=EGk7jmwM0GlInSXFhG37Z_LQ9rRjZACCqJJQIxgdnVeak6NDMhHLAAA.; expires=Sat, 02-Feb-2019 12:10:26 GMT; Max-Age=31536000; path=/; domain=.etsy.com Content-Type: text/plain;charset=UTF-8 Content-Length: 54 Accept-Ranges: bytes Date: Fri, 02 Feb 2018 12:10:26 GMT Via: 1.1 varnish Connection: close X-Served-By: cache-ams4129-AMS X-Cache: MISS X-Cache-Hits: 0 X-Timer: S1517573426.251245,VS0,VE359 [body_sent] => quantity=123456&title=string&description=text&price=12.3456&materials=wood%2C%20plastic&shipping_template_id=123456&shop_section_id=123456&image_ids=1&non_taxable=0&state=active&processing_min=123456&processing_max=123456&category_id=123456&taxonomy_id=123456&tags=fashion%2C%20othertag&who_made=collective&is_supply=1&when_made=2000_2009&recipient=men&occasion=baptism&style=style1%2C%20style2 [body_recv] => This method requires scope authentication not granted. )

Filename: /var/www/html/etsy/vendor/inakiabt/etsy-php/src/Etsy/EtsyClient.php

Line Number: 67

Backtrace:

File: /var/www/html/etsy/vendor/inakiabt/etsy-php/src/Etsy/EtsyApi.php
Line: 68
Function: request

File: /var/www/html/etsy/vendor/inakiabt/etsy-php/src/Etsy/EtsyApi.php
Line: 204
Function: call_user_func_array

File: /var/www/html/etsy/application/controllers/Welcome.php
Line: 77
Function: __call

File: /var/www/html/etsy/index.php
Line: 315
Function: require_once

How Can I add permission in url : like $url = "https://openapi.etsy.com/v2/listings".$listing_id."?scopes=listings_w";

Or is there any way to solve this ? Please help me with this. I am in a great problem with this. Have been stucked since 1 month.
Thank you.

Adding attribute to an item.

I am not sure if it's support attributes to an item. I looked into documentation as well as into the code base there is no such info. Can you help us to explain? Thanks.

The requested redirect URL is not permitted.

Hi there,
I am running order processing for my onlineshop on my localhost using xampp.
I would like to integrate etsy orders as well, to minimize manual copy & paste for product personalization.

However, no matter what I do, I keep getting the following error:
The requested redirect URL is not permitted.

I added a ssl certificate, so using https now, and I use the hosts file and a "abcdefg.local" domain style for the redirect URL.
Can anyone tell me, if it is even possible to use a locally hosted installation as a redirect url? And if so, how?

I am really at a loss atm, so any hint would be greatly appreciated.
Thanks in advance!

Validator fails if price is an integer for createListing method

The data validator fails if the given price is an integer for createListing method. I think the validator should support an two-type check so that it can check against int and float at same time.

A quick, dirty fix would be to change the supported type from float to string in methods.json and always provide the price as a string.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.