Monday, May 14, 2012

$facebook -> getUser() returns wrong value?

The question is the same as title. I'm using the latest php-sdk (v3.1.1) to operate server-side authentication flow.



I have 2 tabs in Chrome, one is my Facebook page and the other is php test page. These 2 problems happen many times:




  • $facebook->getUser() still returns 0 even when I logged in.

  • $facebook->getUser() still returns an ID even when I logged out.



I have to do a work-around of this: try initiating a graph API request with provided access_token, and check if $response->error->type == "OAuthException" to ensure there's an active session or not.



Is there any way to use $facebook->getUser() "stably"? I've searched a lot through SO but not found best answer for php-sdk 3.1.1 yet.



Highly appreciate any helps. Thanks.





No comments:

Post a Comment