需要有关 Facebook 登录的帮助。当我尝试登录并获取
acess_token
以使用 Facebook API 时,收到错误“看起来此应用程序不可用”。
而且我找不到明确的答案为什么会出现这个错误。 我向 Facebook 请求的权限是:
pages_read_engagement
、pages_show_list
根据不同的答案(包括 Stack Overflow 上的答案),我尝试了以下解决方案:
email
和 public_profile
权限设置为高级访问就我而言,我收到此错误是因为我在
Facebook Login for Business上使用
configId
而不是 config_id
。
FB.login(
function(response) {
console.log(response);
},
{
config_id: '<CONFIG_ID>' // right
// configId: '<CONFIG_ID>' // wrong
}
);
我认为您正在使用
Facebook Login For Business
而不是 Facebook login
。
在这种情况下,您需要创建一个特定的配置并在您的
FB Login Button
中使用它。
完整示例代码:
<!DOCTYPE html>
<html>
<head>
<title>Facebook Login JavaScript Example</title>
<meta charset="UTF-8">
</head>
<body>
<script>
function statusChangeCallback(response) { // Called with the results from FB.getLoginStatus().
console.log('statusChangeCallback');
console.log(response); // The current login status of the person.
if (response.status === 'connected') { // Logged into your webpage and Facebook.
testAPI();
} else { // Not logged into your webpage or we are unable to tell.
document.getElementById('status').innerHTML = 'Please log ' +
'into this webpage.';
}
}
function checkLoginState() { // Called when a person is finished with the Login Button.
FB.getLoginStatus(function(response) { // See the onlogin handler
statusChangeCallback(response);
});
}
window.fbAsyncInit = function() {
FB.init({
appId : '{app-id}',
cookie : true, // Enable cookies to allow the server to access the session.
xfbml : true, // Parse social plugins on this webpage.
version : 'v17.0' // Use this Graph API version for this call.
});
FB.getLoginStatus(function(response) { // Called after the JS SDK has been initialized.
statusChangeCallback(response); // Returns the login status.
});
};
function testAPI() { // Testing Graph API after login. See statusChangeCallback() for when this call is made.
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Successful login for: ' + response.name);
document.getElementById('status').innerHTML =
'Thanks for logging in, ' + response.name + '!';
});
}
</script>
<!-- The JS SDK Login Button -->
<fb:login-button
config_id="{configurationId}"
onlogin="checkLoginState();">
</fb:login-button>
<div id="status">
</div>
<!-- Load the JS SDK asynchronously -->
<script async defer crossorigin="anonymous" src="https://connect.facebook.net/en_US/sdk.js"></script>
</body>
</html>
我也遇到了同样的问题,尽管我自己没有对应用程序设置进行任何更改,但我的 Facebook 登录已更改为 Facebook 企业登录。然后,我按照教程在应用程序的侧面板 -> Facebook Login for Businesses -> 配置中创建配置。您会得到一个 config_id,我将其附加到我用于调用手动对话框的现有查询字符串中。我这边的绳子看起来像这样:
https://www.facebook.com/v17.0/dialog/oauth?client_id=XXXXXXXXX&redirect_uri=https://XXXXXXX.COM&state=some_string&config_id=XXXXXXXXX
之后我可以成功请求access_token