Shaun
Shaun

Reputation: 2181

Setting user ID in facebook php sdk?

I'm using a third party class that logs my Flash AIR iOS app into facebook.

I then want to log the user into my online database so they can access membership specific data.

To do this, I'm sending the token and user ID my iOS app receives from the thrid party login class to my php script, and set the token like:

$facebook->setAccessToken($token);

I then need to run...

$user_id = $facebook->getUser();

...so that FB can authenticate that token, so my server knows - yep - this token and id are legit - log this user id in or set up a new account if this id doesn't exist.

My questions:

  1. the token the third party class returns is in this format:

expiry:64092211200000,Token is:CAAFvX6hOtj0BAFNcfr5xgixZAQAaf3Oqljsn3Sy946104f96CiTeZAHuGFoEiZAJTwyx6GMICKlCjj7YAXrE8bUuLKaTMIsUJYYJ9rGmiru3T9Fu6j2xwGxH0tLsMM3PdgL9Ox695wjSGE0sp4djcbHTXBIAvQ9dbfJ5kAXjRWmEoGfdASLeN8ndQeqhIKJzWNykx2SXHBjsE9XHIycaDHqfreMVXYAZDZD

Should I be using all that as the argument for $facebook->setAccessToken($token); , or just the string that comes after "Token is:"?

  1. Once the token is set, is that enough to run $user_id = $facebook->getUser(); , or do I also need to set the user's id somewhere in the sdk? If so, where, as there's no setUser() func.

Thanks for your time and help.

Upvotes: 0

Views: 234

Answers (1)

Aaron J Lang
Aaron J Lang

Reputation: 2098

The access token is just the part after 'Token is:', so in this case: CAAFvX6hOtj0BAFNcfr5xgixZAQAaf3Oqljsn3Sy946104f96CiTeZAHuGFoEiZAJTwyx6GMICKlCjj7YAXrE8bUuLKaTMIsUJYYJ9rGmiru3T9Fu6j2xwGxH0tLsMM3PdgL9Ox695wjSGE0sp4djcbHTXBIAvQ9dbfJ5kAXjRWmEoGfdASLeN8ndQeqhIKJzWNykx2SXHBjsE9XHIycaDHqfreMVXYAZDZD

Setting the access token is enough, there's no need to explicitly set the user id in the PHP facebook SDK.

Upvotes: 1

Related Questions