all.js - FB.getSession与OAuth2不兼容
all.js - FB.getSession incompatible with OAuth2
我包括这样的FaceBook JS SDK:
<script src="http://connect.facebook.net/en_US/all.js">
但是最终我在FireBug中得到这个错误:
FB.getSession incompatible with OAuth2. http://connect.facebook.net/en_US/all.js
我完全迷路了。从昨天开始我就一直想弄清楚到底发生了什么事,但是没有运气。我做错了什么吗?
Get Session函数不再使用。FB。getAuthResponse方法是FB的替代品。getSession方法,在迁移到OAuth 2.0后已弃用。
https://developers.facebook.com/docs/reference/javascript/FB.getAuthResponse/请参阅https://developers.facebook.com/docs/oauth2-https-migration/-您可能需要重新访问Javascript和身份验证文档- oauth迁移是强制性的10月1日,这将破坏不兼容的应用
尝试以下修改:
1) Upgrade to Facebook PHP SDK 3.1.1 (if you are using that)
2) Modify <fb:login-button> "perms" attribute to "data-scope"
Before:
<fb:login-button perms="email" on-login="my_function_login_complete(arguments)">
Facebook Logon
</fb:login-button>
After fix:
<fb:login-button data-scope="email" on-login="my_function_login_complete(arguments)">
Facebook Logon
</fb:login-button>
3) Replace JavaScript function call "FB.getSession" for "FB.getAuthResponse"
4) Alter JavaScript function parameter "response" in "FB.login()"
a) response.session => response.authResponse
b) response.session.access_token => response.authResponse.accessToken
Before:
FB.login(function(response) {
if (response.session) {
console.log("User is connected to the application.”);
var accessToken = response.session.access_token;
}
});
After fix:
FB.login(function(response) {
if (response.authResponse) {
console.log("User is connected to the application.”);
var accessToken = response.authResponse.accessToken;
}
});
5) Alter JavaScript function parameter "response" in "FB.getLoginStatus()"
a) response.session.user_id => response.authResponse.userID
b) response.session.access_token => response.authResponse.accessToken
Before:
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
var uid = response.session.user_id;
var accessToken = response.session.access_token;
...
After fix:
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
var uid = response.authResponse.userID;
var accessToken = response.authResponse.accessToken;
...
更多细节在这里:https://developers.facebook.com/blog/post/503https://developers.facebook.com/blog/post/525
祝你好运!:)
相关文章:
- TypeError:在不兼容的接收器nodejs上调用了方法Uint8Array.length
- CKJustify和Color Button插件之间的不兼容
- 在不兼容的接收器上调用的方法Set.prototype.add未定义
- 如果不兼容,则隐藏范围输入
- 谷歌图表 - 地理图表“不兼容的数据表:错误:未知地址类型
- IE11真的与getNamedItem()JS函数不兼容吗
- 与您的操作系统或体系结构不兼容:fsevents@1.0.11.
- jQuery脚本滚动在iDevices上不兼容
- three.js javascript/raycasting代码与retina显示器Mac不兼容
- TypeScript无效的重载签名-与实现不兼容
- PHP JSON编码输出与Javascript Ajax不兼容
- ACE编辑器applyDeltas似乎与setTimeout不兼容
- Element.insertAdjacentHTML与引导程序类之前和之后的::不兼容
- Geocoding和Animation.drop与超时不兼容
- 如何让我的html5功能不兼容警告使用javascript工作
- 不兼容的数据表: 错误:表包含的列数超过预期
- HTML5 不兼容的浏览器测试
- 有什么方法可以将类型指定为 self?或解决方法“属性类型不兼容”
- React 15 与 React-redux 不兼容
- all.js - FB.getSession与OAuth2不兼容