PHP Classes

Etsy API - not able to retrieve transaction details

Recommend this page to a friend!

      PHP OAuth Library  >  All threads  >  Etsy API - not able to retrieve...  >  (Un) Subscribe thread alerts  
Subject:Etsy API - not able to retrieve...
Summary:However, im able to get the product listing already
Messages:9
Author:Wong Gar Kit
Date:2015-07-21 09:23:53
 

  1. Etsy API - not able to retrieve...   Reply   Report abuse  
Picture of Wong Gar Kit Wong Gar Kit - 2015-07-21 09:23:53
Dear Manuel Lemos,
First of all, THANK YOU SOOOOO MUCH for sharing this OAuth class!!! I've been searching around about 3days!

With your sample code, firstly i able to retrieve user/shop details. then i tried set the scope to transactions_r, its not working, so i tried for listings_r (i refer to previous post that you said need to run this ResetAccessToken function ), its working.

Anyway, im not able to retrieve the transactions_r even i follow the steps to retrieve the listings_r.
this is the error i get:
-----------------------------------------------------------------
OAuth client error

Error: it was not possible to access the API call: it was returned an unexpected response status 403 Response: This method requires scope authentication not granted.
------------------------------------------------------------------

May i know what is the problem, and how should i solve this?
Thank you very much!!

Best Rgds,
Gar Kit

  2. Re: Etsy API - not able to retrieve...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2015-07-21 15:53:08 - In reply to message 1 from Wong Gar Kit
If you have reset the access token before changing the scope and calling the API URL you want and it does not work, maybe you are not using the correct scope type.

I recommend that you double-check the documentation of the API you want to call. Can you tell the URL of the documentation page for that API call?

  3. Re: Etsy API - not able to retrieve...   Reply   Report abuse  
Picture of Wong Gar Kit Wong Gar Kit - 2015-07-22 01:46:15 - In reply to message 2 from Manuel Lemos
everything is working today ><""""
i able to set the scope to 'transactions_r' now. And for this scope, i can retrieve shop details, listing as well as transaction details.

these are my code
...

$client->ResetAccessToken();
//$client->scope = 'listings_r'; //working yesterday, but i din try today, worried not able to reset again and not able to retrieve transaction

//$client->scope = 'transactions_r'; //not working yesterday, but working today.
$client->scope = 'email_r%20listings_r%20listings_w%20transactions_r%20'; //not working? but from the documentation, email_r%20listings_r is the example scope?

...
//working today ><""""
$success = $client->CallAPI(
'https://openapi.etsy.com/v2/shops/6167973/transactions',
'GET', array(), array('FailOnAccessError'=>true), $user);
}
...

below is the Etsy API Documentation Page:
etsy.com/developers/documentation/g ...


New Question:
1) Can i run this as cron job? will it ask me to allow access since there is no interface for me to click in cron job? or session is also available in cron job, so i do not need to keep the data manually?
2) if i want to update listing (scope = listings_w), i need to reset the access token again? what if fail again as yesterday i was not able to reset to 'transaction_r'?


Deeply appreciate your help..
Best Rgds
Gar Kit

  4. Re: Etsy API - not able to retrieve...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2015-07-22 02:13:10 - In reply to message 3 from Wong Gar Kit
I suspect that the %20 sequence in the scope should be replaced with a space.

As for running as cron jobs, the user is not present. The default storage for access tokens is session variables. Since sessions do not work when the Web user is not present, you need to use another storage method like a database.

To learn how to do it, you should read these articles:

phpclasses.org/blog/package/7700/po ...

phpclasses.org/blog/package/7700/po ...

As for scopes, each token has one group of scopes associated with it. If you request a token with all the scopes you need, you can use that token for any API calls those scopes allow.

  5. Re: Etsy API - not able to retrieve...   Reply   Report abuse  
Picture of Wong Gar Kit Wong Gar Kit - 2015-07-22 05:51:52 - In reply to message 4 from Manuel Lemos
Dear Manuel Lemos,
You're really a very very very kind genius!!
i've tried the offline access to Etsy API.


The only mistake i faced:
MYSQL table : oauth_session
changes : added 2 column refresh_token & access_token_response


New concern:
I only need to run mysqli_login_with_etsy.php ONCE, do i?
after "allow access" i can always connect to the etsy API?
No need to run mysqli_login_with_etsy.php anymore?
I can put mysqli_offline_access_to_etsy.php in my cron job, can i?
The data (token etc) i get & set in the database will always work?
Do i need to do extra step to renew the token?

ThanksssssSS for the help!
Best Rgds,
Gar Kit

  6. Re: Etsy API - not able to retrieve...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2015-07-22 16:20:30 - In reply to message 5 from Wong Gar Kit
You are probably using an older version of the class package because the current one has the refresh_token and access_token_response in the definition file oauth.sql.

Anyway, once you obtain a valid token with a refresh token, the class will automatically renew the token when it expires. Just make sure your machine clock is accurate or at least not delayed.

Also keep in mind that the token may be revoked for some reason. In that case it is necessary to restart the process as it will not refresh a revoked token.

  7. Re: Etsy API - not able to retrieve...   Reply   Report abuse  
Picture of Wong Gar Kit Wong Gar Kit - 2015-07-24 04:13:20 - In reply to message 6 from Manuel Lemos
Im facing one problem now :(

FYI, im able to update the etsy quantity if i call the page manually. Anyway, it failed to if i put it in cron job (lets say, i call 5 files in one php file. the previous 3files no issue, but the 4th (update etsy quantity) & 5th is not working)

Do you know what is the issue?
Thank you very much...

  8. Re: Etsy API - not able to retrieve...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2015-07-24 23:19:57 - In reply to message 7 from Wong Gar Kit
You need to enable the error logging and see what the error message says because without that information I have no way to guess what is going on.

  9. Re: Etsy API - not able to retrieve...   Reply   Report abuse  
Picture of Wong Gar Kit Wong Gar Kit - 2015-07-30 01:43:34 - In reply to message 8 from Manuel Lemos
thank you very much, API part is done :))