凡使用PHP SDK请求延长访问令牌的Facebook应用 [英] Where to request extended access token in Facebook App using PHP SDK

查看:260
本文介绍了凡使用PHP SDK请求延长访问令牌的Facebook应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要访问我的用户的信息时,它们是离线的,我知道我需要使用为期60天延长访问令牌。我一直在寻找这个SO发布<一个href=\"http://stackoverflow.com/questions/8982025/how-to-extend-access-token-validity-since-offline-access-de$p$pcation\">How延长访问令牌的有效性,因为offline_access德precation 这说我需要在我的base_facebook.php文件中规定的方法,使该方法的调用。

I need to get access to my user's information when they are offline and I understand that I need to use an extended access token which lasts 60 days. I have been looking at this SO post How to extend access token validity since offline_access deprecation and this says that I need to include the stated method in my base_facebook.php file and make a call to the method.

不过,希望通过我的code就有机会获得令牌没有明确的要求或任何地方使用,所以我不知道该如何申请延长访问令牌。这篇文章我需要使用访问标记中的Facebook API ?解释说,使用PHP SDK的访问令牌自动添加到API请求,这可以解释为什么我从来没有遇到过的访问令牌为止。

However, looking through my code there is no explicit request or use of access tokens anywhere so I'm unsure how to request an extended access token. This post Do I need to use access token in Facebook API? explains that using the PHP SDK the access token is automatically appended to the api requests, which would explain why I have never encountered access tokens so far.

所以我的问题是如何获取用户,当他们在使用PHP SDK方法签名给一个扩展的访问令牌getExtendedAccessToken()?

So my question is how do I get the user to give an extended access token when they sign in using the PHP SDK method getExtendedAccessToken()?

编辑:这里的一个关键点是,你似乎无法得到扩展的访问令牌为自己的应用程序!我想这与我的测试用户之一,它工作得很好!还有一点要注意的是,访问令牌工具将默认情况下只显示究竟是谁开发的应用程序的人的访问令牌。要查看你需要去调试器部分,输入访问令牌有其他用户访问令牌的细节。希望这有助于。

推荐答案

如果您还没有看到访问令牌的任何引用,他们最有可能被存储在会话变量。你可以尝试添加回声&LT; pre&gt;中;的print_r($ _ SESSION);出口(0); 您code看到的是存储什么在会话中。您已经登录后,你会的地方添加它。

If you haven't seen any references to access tokens, they are most likely being stored in session variables. You could try adding echo "<pre>";print_r($_SESSION);exit(0); to your code to see what is stored in the session. You would add it somewhere after you have already been logged in.

如果你调用从PHP SDK getExtendedAccessToken(),然后返回的访问令牌会自动长寿命。若要检索它,他们被定向到你的网站后,您可​​以使用getAccessToken()方法。这样,你会存储返回的值,当你要与setAccessToken($ stored_token)后拨打电话使用它。

If you are calling getExtendedAccessToken() from the PHP SDK, then the access token returned will automatically be long lived. To retrieve it after they are directed back to your site, you can use the getAccessToken() method. You would then store the returned value, and use it when you want to make calls later with setAccessToken($stored_token) .

希望有所帮助。

这篇关于凡使用PHP SDK请求延长访问令牌的Facebook应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆