Skip to content
This repository was archived by the owner on Jan 13, 2022. It is now read-only.

[4.0][Fix] Fix stdClass error on FacebookRedirectLoginHelper #393

Merged

Conversation

SammyK
Copy link
Contributor

@SammyK SammyK commented Apr 3, 2015

In Graph v2.2 and below, GET requests to the /oauth/access_token endpoint would return a query string in the body of the response:

access_token=foo_token&expires=5183759

Starting in Graph v2.3, the response body is json:

{"access_token":"foo_token","token_type":"bearer","expires_in":5183686}

Since v4.0 of the PHP SDK translated these two responses differently, it was causing errors for anyone using Graph v2.3 (#391, #392 and even here). This PR is an ugly hack to fix this without BC's. :)

Not sure if this response change will affect any other places in 4.0, but if we get any more issues about stdClass errors, you can bet it's due to the Graph response change.

Version 4.1 of the SDK is unaffected.


// Graph v2.3 and greater return objects on the /oauth/access_token endpoint
$accessToken = null;
if ($response instanceof \stdClass && isset($response->access_token)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_object($response) :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can also use property_exists($response, 'access_token'), maybe, I'm +0 about that haha Go for consistency with the below if statement

@SammyK SammyK force-pushed the 4.0-access-token-response-fix branch from 6ab56c1 to 46d5de0 Compare April 3, 2015 17:27
@SammyK
Copy link
Contributor Author

SammyK commented Apr 3, 2015

Thanks @yguedidi! Rebased. :)

gfosco added a commit that referenced this pull request Apr 3, 2015
[4.0][Fix] Fix stdClass error on FacebookRedirectLoginHelper
@gfosco gfosco merged commit d620878 into facebookarchive:4.0-dev Apr 3, 2015
@SammyK SammyK deleted the 4.0-access-token-response-fix branch May 6, 2015 17:26
@goldsatish
Copy link

god job keep it up! yes i updated code then after working...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants