脸书应用程序有错误

Facebook app with error

本文关键字:有错误 应用程序      更新时间:2023-09-26

我不是Facebook应用程序专家。我从FB网站上获取了此代码,并对其进行了修改,使其与我的应用程序ID一起使用(这是我唯一更改的内容。我也添加了一些警报)。然后我尝试从本地网页使用此代码(即:该页面在我的桌面上,但我的笔记本电脑已连接到互联网)。

每当我运行此代码时,我都会弹出一个浏览器弹出窗口,显示此错误:"MyAppName 出错。请稍后再试。

有人可以告诉我这里发生了什么吗?似乎FB.getLoginStatus也从未被调用过。

任何帮助,不胜感激。

// initialize the library with the API key
FB.init({ appId: 'myAppID',frictionlessRequests:true });
// fetch the status on load
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
// the user is logged in and has authenticated your
// app, and response.authResponse supplies
// the user's ID, a valid access token, a signed
// request, and the time the access token 
// and signed request each expire
var uid = response.authResponse.userID;
var accessToken = response.authResponse.accessToken;
} else if (response.status === 'not_authorized') {
alert("1. not");
// the user is logged in to Facebook, 
// but has not authenticated your app
} else {
alert("2. alert");
// the user isn't logged in to Facebook.
}
});
$('#login').bind('click', function() {
FB.login(handleSessionResponse);
});
$('#logout').bind('click', function() {
FB.logout(handleSessionResponse);
});
$('#disconnect').bind('click', function() {
FB.api({ method: 'Auth.revokeAuthorization' }, function(response) {
clearDisplay();
});
});
// no user, clear display
function clearDisplay() {
$('#user-info').hide('fast');
}
// handle a session response from any of the auth related calls
function handleSessionResponse(response) {
// if we dont have a session, just hide the user info
alert("entered handleSessionResponse");
if (response.authResponse) {
alert('Welcome!  Fetching your information.... ');
FB.api('/me', function(response) {
alert('Good to see you, ' + response.name + '.');
});
} else {
alert('User cancelled login or did not fully authorize.');
}
if (!response.session) {
clearDisplay();
return;
}
}

您是否将属性myAppID更改为您正在使用的Facebook应用程序的ID?

FB.init({ appId: 'myAppID',frictionlessRequests:true });

myAppID应包含一个唯一的 Facebook 应用程序 ID,您可以在 Facebook 应用程序页面上获取该 ID。也许您只是复制了代码而没有更改它。