Facebook graph api FB.ui方法';身份验证登录';韩元';行不通
它不会打开任何东西Facebook graph api FB.ui方法';身份验证登录';韩元';行不通,facebook-graph-api,Facebook Graph Api,它不会打开任何东西 function logIN() { FB.ui({ method: 'auth.login', perms: 'email', display: 'iframe' }, function(response) { /* */ }); } 我认为这应该是你的职责: FB.ui({ method: 'oauth', display: 'popup', sc
function logIN()
{
FB.ui({
method: 'auth.login',
perms: 'email',
display: 'iframe' },
function(response) {
/* */
});
}
我认为这应该是你的职责:
FB.ui({
method: 'oauth',
display: 'popup',
scope: 'email',
response_type: 'token',
redirect_uri: 'WHEREYOUWANTTOPROCESSTOKEN',
client_id: 'YOURAPPID',
});
请注意,只有页面
或弹出窗口
是显示的有效类型
此示例可能有助于:
登录
函数更新按钮(响应){
console.log('更新按钮',响应);
var button=document.getElementById('fb-auth');
if(response.session){
button.innerHTML='Logout';
button.onclick=函数(){
FB.注销(功能(响应){
log('FB.logout callback',response);
});
};
}否则{
button.innerHTML='Login';
button.onclick=函数(){
FB.登录(功能(响应){
log('FB.login callback',response);
if(response.session){
console.log(“用户已登录”);
}否则{
console.log(“用户已注销”);
}
});
};
}
}
//使用当前状态运行一次,也可以在状态更改时运行一次
FB.getLoginStatus(更新按钮);
FB.Event.subscribe('auth.statusChange',updateButton);
(-1)显示必须是以下其中之一:1-弹出2-对话框3-iframe 4-触摸5-异步5-隐藏6-非这些参数可以与其他对话框一起使用,但我认为身份验证对话框只允许页面和弹出来保护身份验证过程的这一重要阶段。触摸在这里也可能有效,但它可能对手机以外的任何东西都没有用处。如果使用页面显示,这是服务器的响应:)scope:“email”
对我不起作用,但perms:“email”
似乎起作用。另外,重定向uri不起作用。
<button id="fb-auth">Login</button>
<script>
function updateButton(response) {
console.log('Updating Button', response);
var button = document.getElementById('fb-auth');
if (response.session) {
button.innerHTML = 'Logout';
button.onclick = function() {
FB.logout(function(response) {
console.log('FB.logout callback', response);
});
};
} else {
button.innerHTML = 'Login';
button.onclick = function() {
FB.login(function(response) {
console.log('FB.login callback', response);
if (response.session) {
console.log('User is logged in');
} else {
console.log('User is logged out');
}
});
};
}
}
// run it once with the current status and also whenever the status changes
FB.getLoginStatus(updateButton);
FB.Event.subscribe('auth.statusChange', updateButton);
</script>