rhysnhall / etsy-php-sdk

PHP SDK for Etsy API v3.
MIT License
47 stars 36 forks source link

Issue with returned values from requestAccessToken #18

Closed vintagetwinmike closed 1 year ago

vintagetwinmike commented 1 year ago

First of all, thanks for putting this together. I primarily wanted it for the Oauth2 functions because that code challenge stuff didn't make any sense to me, and seeing as it took me 2 months just for Etsy to grant me API access, I didn't feel like wasting more time trying to figure out how to just get a damn access token from their friggin API!

Everything worked until the access/refresh token name/values were passed back. So I had to change this: return [ 'access_token' => $response->access_token, 'refresh_token' => $response->refresh_token ];

to this: return [ $response->access_token, $response->refresh_token ];

Otherwise this doesn't work: [$access_token, $refresh_token] = $client->requestAccessToken($....

Just returning the values without the names worked as expected.

rhysnhall commented 1 year ago

Hey, thanks for the kind words. It motivates me to get back in and work on this package again!

Yep, so the issue there comes down to PHP version. Prior to PHP 7.1, it was not possible to use an associative array with the PHP list() function. It only supported numerical arrays in prior versions.

Certain parts of the package use syntax from > PHP 7.1, so if you intend to use the whole package, I suggest upgrading your version. Otherwise, if you only wanted the Auth and got it all working, that's good to hear!

vintagetwinmike commented 1 year ago

Thanks man, I figured it would be a php version issue. Was not aware associative array support was added. I suppose it's time for me to upgrade and get caught up. Yeah, everything is working on the authentication side of things, which is all I really needed. Greatly appreciate the response and the code! Definitely keep working on it, I think it will be a great help to a lot of folks now that Etsy is finally approving access again.