在使用 facebook 的新 JavaScript SDK 时,我在尝试时遇到以下错误
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);}());
window.fbAsyncInit = function(e) {
var curLoc = window.location;
var channel = curLoc.protocol + "//" + curLoc.hostname + (curLoc.pathname).substr(0,(curLoc.pathname).lastIndexOf('/')) + "/channel.html";
FB.init({ appId: APP_ID,
status: true,
cookie: true,
xfbml: true,
channelUrl: channel,
oauth: true});
FB.getLoginStatus(isUserLoggedIn);
FB.Canvas.setAutoGrow();}
Uncaught Error: FB.Auth.setAuthResponse only compatible with OAuth2
造成这种情况的原因是什么?我的应用程序处于 SSL 模式,我似乎无法弄清楚为什么会出现该错误。
最佳答案
这肯定是唯一包含 JS SDK 的地方吗?检查复制/粘贴的 Like 按钮初始化代码等。
我发现当人们在 URL 中包含带有某些参数的 JS SDK 时会发生此错误(即在某处包含//connect.facebook.net/en_US/all.js#appid=x ) - 这会覆盖一些FB.init 调用中的参数可能会导致您收到错误消息
关于facebook - Uncaught Error ...FB.Auth.setAuthResponse 仅与 OAuth2 兼容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7799253/