Git Product home page Git Product logo

Comments (13)

bwardy avatar bwardy commented on August 20, 2024 1

@iDontWantAUsername well... I'm out. I'm VERY new to this. :)

from stravaphp.

notflip avatar notflip commented on August 20, 2024 1

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()?

from stravaphp.

bwardy avatar bwardy commented on August 20, 2024

I also have the same issue.

from stravaphp.

bwardy avatar bwardy commented on August 20, 2024

@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.

from stravaphp.

iDontWantAUsername avatar iDontWantAUsername commented on August 20, 2024

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.

from stravaphp.

maltehuebner avatar maltehuebner commented on August 20, 2024

Looks like this issue is releated to #45. I fixed the problem other there, unfortunately the fix was not accepted.

from stravaphp.

vredeling avatar vredeling commented on August 20, 2024

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.

from stravaphp.

djjavo avatar djjavo commented on August 20, 2024

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?

private function getResponse($method, $path, $parameters)
{
try {
$response = $this->adapter->request($method, $path, $parameters);
return $this->getResult($response);
}
catch (\Exception $e) {
return $e->getMessage();
}
}

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?

from stravaphp.

vredeling avatar vredeling commented on August 20, 2024

@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

from stravaphp.

vredeling avatar vredeling commented on August 20, 2024

@djjavo I'm closing this issue. If you want the $e->getMessage() issue addressed, please open a separate issue or PR.

from stravaphp.

vredeling avatar vredeling commented on August 20, 2024

@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.

from stravaphp.

djjavo avatar djjavo commented on August 20, 2024

@vredeling I've suggested a non-breaking change (#67) for users of StravaPHP that require extra information in the response.

from stravaphp.

vredeling avatar vredeling commented on August 20, 2024

@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.

from stravaphp.

Related Issues (20)

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.