开发者

Facebook connect not returning the session in the expected format

I've been trying to add Facebook Connect to a website, but it didn't seem to get the user id after logging in. So, after a bit of checking around, I discovered what seems to be the problem:

The facebook library expects $_REQUEST['session'] to exist (in the getSession() function), but when I output the $_REQUEST, I get this structure:

Array
(
    [url] 
    [base_domain_AppID]
    [AppID]
    [AppID_user] 
    [AppID_ss] 
    [AppID_session_key]
    [AppID_expires] 
)

where AppID is the application id.

Any idea why this is happening?

I see that the $_REQUEST['session'] is supposed to have some fields called 'uid', 'access_token' and 'sig'.. the 'uid' is AppID_user, but I have no idea about the other two. I'm thinking that, if there's no other solution, I can convert this data to the object it's expecting, so it can pass the validateSessionObject() function.

开发者_JS百科

I don't know if this is relevant, but this happens regardless of whether I enable cookie support or not.

I downloaded the libraries today, so I don't think I'm using an older version of them.

Edit: in the meantime, I've managed to match most of the fields in my $_REQUEST to the ones expected in the session, except that there's no field called 'access_token'.


I had the same problem and the problem was that i was generating the facebook authentication url myself as

https://graph.facebook.com/oauth/authorize?client_id=$client_id&scope=$scope&redirect_uri=$redirect_uri

Instead, when you create the login url using the facebook class, it generates it as a longer version, including 2 important fields : return_session=1,session_version=3

If these fields are not included in the auth url, the redirect does not generate the session value.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜