FB登录按钮不提示首次用户输入范围 ” window.fbAsyninit=函数() { FB.init({ appId:'ID', 状态:正确, 曲奇:是的, xfbml:对 }); FB.getLoginStatus(函数(响应) { 如果(response.status===“已连接”) { if(response.authResponse!=“未定义”) { window.location='/fb_redirect.php'; } }else if(response.status===“未授权”) { }否则 { FB.Event.subscribe('auth.login',函数(响应) { window.location='/fb_redirect.php'; }); } }); }; (功能(d、s、id){ var js,fjs=d.getElementsByTagName[0]; if(d.getElementById(id))返回; js=d.createElement;js.id=id; js.src='//connect.facebook.net/en_US/all.js#xfbml=1&appId=ID'; fjs.parentNode.insertBefore(js,fjs); }(文档“脚本”、“facebook jssdk”);
这就是我现在正在使用的。对于已经接受该应用程序的用户来说,它工作得很好。但是,对于第一次使用该应用程序的用户来说,在单击“登录”按钮时,不会弹出任何屏幕,显示有关该应用程序的详细信息,例如有多少人使用该应用程序,或者该应用程序请求的权限类型。它直接指向/fb_redirect.phpFB登录按钮不提示首次用户输入范围 ” window.fbAsyninit=函数() { FB.init({ appId:'ID', 状态:正确, 曲奇:是的, xfbml:对 }); FB.getLoginStatus(函数(响应) { 如果(response.status===“已连接”) { if(response.authResponse!=“未定义”) { window.location='/fb_redirect.php'; } }else if(response.status===“未授权”) { }否则 { FB.Event.subscribe('auth.login',函数(响应) { window.location='/fb_redirect.php'; }); } }); }; (功能(d、s、id){ var js,fjs=d.getElementsByTagName[0]; if(d.getElementById(id))返回; js=d.createElement;js.id=id; js.src='//connect.facebook.net/en_US/all.js#xfbml=1&appId=ID'; fjs.parentNode.insertBefore(js,fjs); }(文档“脚本”、“facebook jssdk”);,facebook,facebook-javascript-sdk,facebook-login,Facebook,Facebook Javascript Sdk,Facebook Login,这就是我现在正在使用的。对于已经接受该应用程序的用户来说,它工作得很好。但是,对于第一次使用该应用程序的用户来说,在单击“登录”按钮时,不会弹出任何屏幕,显示有关该应用程序的详细信息,例如有多少人使用该应用程序,或者该应用程序请求的权限类型。它直接指向/fb_redirect.php 查看pic中指定的站点URL?这是登录FB并接受应用程序时页面重定向到的URL吗?当用户未登录facebook时,使用登录按钮,如果用户已登录但未授予应用程序权限,则应使用oauth对话框 你可以这样做 "<
查看pic中指定的站点URL?这是登录FB并接受应用程序时页面重定向到的URL吗?当用户未登录facebook时,使用登录按钮,如果用户已登录但未授予应用程序权限,则应使用oauth对话框 你可以这样做
"<div id='fb-root'></div>
<script>
window.fbAsyncInit = function()
{
FB.init({
appId: 'ID',
status: true,
cookie: true,
xfbml: true
});
FB.getLoginStatus(function(response)
{
if(response.status === 'connected')
{
if (response.authResponse != 'undefined')
{
window.location = '/fb_redirect.php';
}
} else if(response.status === 'not_authorized')
{
} else
{
FB.Event.subscribe('auth.login', function(response)
{
window.location = '/fb_redirect.php';
});
}
});
};
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = '//connect.facebook.net/en_US/all.js#xfbml=1&appId=ID';
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<div class='fb-login-button' data-show-faces='false' scope='email' registration-url='http://www.sportannica.com/fb_redirect.php' size='large' data-width='200' data-max-rows='1'></div>
正确的语法是
data scope=“email”
,而不是scope=“email”“
谢谢。但是,在fb_重定向文件中。。。会话已启动,或者如果是第一次用户,将执行插入查询。所有这些都需要在登录按钮所在的页面上发生吗?你能更好地解释一下吗?我现在连接的internet不允许我通过ftp连接到远程服务器。所以,我不能上传你的代码,看看它是否有效。但是,根据以前的经验,window.location='some_other_file.php'从来都不起作用。由于某些原因,window.reload()似乎工作得很好。哦,对不起,重定向可以是任何你想要的,只要它在你的域内。您在应用程序详细信息中指定的url将是接收已签名的\u请求的url。因此,当用户接受应用程序时,我需要通过应用程序使用$user=$facebook->getUser()获取他们的一些信息;
FB.getLoginStatus(function(response) {
if(response.status === 'connected'){
if (response.authResponse != 'undefined')
window.location = '/fb_redirect.php';
}else if(response.status === 'not_authorized'){
//it means we have a user but he hasn't granted any permissions to our app
//we're going to redirect him to the permission page
window.location = 'https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&response_type=code&redirect_uri=YOUR_APP_URL&scope=email';
} else {
//the user is not logged in, as you already have a login button you don't have to do nothing
}
});
//this should be outside the FB.getLoginStatus function
FB.Event.subscribe('auth.login', function(response) {
window.location = '/fb_redirect.php';
});