开发者

facebook access token for offline_access - PHP

I'm trying to get the status from facebook users, who connect to my app with offline_access and read_stream permissions.

All the processes will use subscription to get notification about new feeds, and then take access to status of the user, who changed it.

The code for subscription works great, I get all info as it should 开发者_运维知识库be, but the problem starts with second part - every time I try to access user status via

$objFacebook->api('/'USER_ID'/statuses?access_token=TOKEN', 'get', $params);

I get the exception:

An access token is required to request this resource

I tried to set access_token which I got when connected to my website via facebook login, also tried to set the whole session in similar way as it is done here:

Array
(
    [access_token] => ... 
    [base_domain] => ...
    [expires] => 0
    [secret] => ...
    [session_key] => ...
    [sig] => ...
    [uid] => ...
)

but it didn't help. On the other side, when I copied my access_token generated via facebook developers (http://developers.facebook.com/docs/reference/api/user/) it works correctly, so it looks like my app generates an incorrect access token.

Do you have any idea where the problem can be?

To connect I use facebook-php-2.0 library.


You should upgrade to version 3 of the PHP SDK. We made some changes to the cookie format and other things you can read about here. Version 2 will stop working on September 1st, so you'll need to upgrade soon anyways. Once you've done that, things should work for you.

P.S. You probably will want to use the "/posts" connection rather than than the "/statuses" connection of the User object as it will also give you any posts the user made that include attachments. The "/statuses" connection will only return text-only posts the user made. We'll update the documentation to clarify that.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜