Closed iDontWantAUsername closed 4 years ago
I also have the same issue.
@iDontWantAUsername I found that I could get the getAthlete() function working.
Change the line:
$service = new REST($token, $adapter);
to:
$service = new REST($token->getToken(), $adapter);
I'm still trying to figure out how to get the getAthleteActivities() function working now.
Thanks @bwardy , i should have been a bit clearer, if i put in a valid Token the request does work as expected.
My issue is that if i am not authorised i should get an exception from Guzzle that i can handle and return the correct message.
I am not getting the handled exceptions i used to get prior to Guzzle. I should be able to use the Exceptions rather than having to run a string comparison on the getAthlete response.
@iDontWantAUsername well... I'm out. I'm VERY new to this. :)
Looks like this issue is releated to #45. I fixed the problem other there, unfortunately the fix was not accepted.
The Guzzle update was quite comprehensive. Also, from 15 jan 2018 onwards there is a change in the authentication process. https://developers.strava.com/docs/oauth-updates/ So I'll try and contact @basvandorst to run over the new issues. To get these hickups ironed out.
I might be a bit late to the party here, but also experiencing similar issues to @iDontWantAUsername.
Would changing the catch block in https://github.com/basvandorst/StravaPHP/blob/master/src/Strava/API/Service/REST.php be beneficial?
https://github.com/basvandorst/StravaPHP/blob/5b2b2a9246434273e5a7b8e9d0333765e0fcafbf/src/Strava/API/Service/REST.php#L71-L80
As opposed to returning $e->getMessage()
, return $e->getResponse()
(or both)? Would enable you to do look at useful data such as the response code?
@djjavo Yes, that would be useful. But requires a bit of a refactor of all the getResponse() calls. Could you supply a pull request on the develop branch of my fork? https://github.com/vredeling/StravaPHP/pulls
@djjavo I'm closing this issue. If you want the $e->getMessage()
issue addressed, please open a separate issue or PR.
Ah this is related to my issue: #65
I'm willing to spend time to make a PR but I'm not sure as to what has to happen exactly.
Would it be an idea to rethrow instead of returning $e->getMessage()
?
@notflip Yes, that would be the idea. I'll review the PR if you supply one.
I'm a bit concerned we're breaking current implementations of the this class again by making a change like this. But it makes a lot of sense to re-throw and have implementations catch the error instead of the message. Or we define a global config variable which sets the response output to text by default. You could change that param to get a throwable instead of the error text.
@vredeling I've suggested a non-breaking change (https://github.com/basvandorst/StravaPHP/pull/67) for users of StravaPHP
that require extra information in the response.
@notflip since this PR #67 has been merged to the latest dev version, it is possible to check the response codes.
Just instantiate the REST client like so:
$service = new REST($token->getToken(), $adapter, 1);
That will give you access to the response headers, body and status codes.
Hi,
i know this perhaps isn't the right place but is anyone having issues handling exceptions since the update to use Guzzle?
This is my example code:
This returns:
I have tried loads of combinations of ClientException and Exception in different namespaces but do not get an exception thrown, as far as i can tell i am copying the readme examples. Does anyone have an idea what is have done wrong? This worked fine and caught the 401 errors with the previous version.
Thanks! Richard