开发者

facebook getting session_key for offline_access in canvas application

Hey everyone, I am trying to get the session_key and secret for a facebook session (offline_access) in canvas application.

However, I am unable to get these two particular variables. When, I am testing the same code locally, I can get the variables above (but this can be because the local app is not a canvas application)

I 'm using the following code, for redirect:

$facebook->getLoginUrl(array(
   'canvas' => 1,
   'fbconnect' => 0,
   'req_perms' => 'user_status,publish_stream,offline_access'
));

Can someone suggest me on how I can grab the session_key and secret, when the user authorizes the application? (for permanent offline access)

Here is an example session dump via Facebook:

Array (
   [uid] => 100000926583671
   [session_key] => 
   [expires] => 0 
   [secret] => 
   [base_domain] => 
   [access_token] => 183043495039366|3ab6ac2asdkhj1bcfdec13d7-100000926583671|jJQaIT-n80YxioAasdwN0cm99U 
   [sig] => 2f64sadasc1da31c12927a052752776
)

and this is the error:

开发者_JS百科
Array (
   [error] => Array (
          [type] => OAuthException 
          [message] => An active access token must be used to query information about the current user. 
          )
   )


session_key and secret are now deprecated, and Facebook wants you to use Oauth authentication schema. Then, you will have to use given access_token (that you correctly get in $session) to make your api calls.

Try:

$session = $facebook->getSession();
$me = $facebook->api('/100000926583671', 
                     array('access_token' => $session['access_token'])
      );
var_dump($me);

Ref: http://developers.facebook.com/docs/authentication/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜