facebook在画布应用程序中获取offline_access的session_key

发布于 2024-10-07 10:43:53 字数 1064 浏览 1 评论 0原文

嘿大家, 我正在尝试在画布应用程序中获取 facebook 会话(offline_access)的 session_keysecret

但是,我无法获得这两个特定变量。 当我在本地测试相同的代码时,我可以获取上面的变量(但这可能是因为本地应用程序不是画布应用程序)

我使用以下代码进行重定向:

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

有人可以建议我如何做当用户授权应用程序时,获取 session_keysecret? (用于永久离线访问)

这是通过 Facebook 转储的示例 session

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

这是错误:

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

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:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

柒夜笙歌凉 2024-10-14 10:43:53

session_keysecret 现已弃用,Facebook 希望您使用 Oauth 身份验证架构。然后,您必须使用给定的 access_token (您在 $session 中正确获取的)来进行 api 调用。

尝试:

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

参考:
http://developers.facebook.com/docs/authentication/

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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文