我在Facebook的开发者页面上创建了2个App ID.我可以使用其中一个应用程序ID获取用户的电子邮件地址,名字,姓氏和ID,但是使用其他应用程序ID,我只获取用户的全名和他/她的ID.
获取所有所需详细信息的App ID的URL在线,而仅获取全名的App ID在我的localhost上.
我正在使用以下代码,
function testAPI() {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Successful login for: ' + response.name);
console.log(JSON.stringify(response));
});
}
Run Code Online (Sandbox Code Playgroud)
所以我的问题是如何从我的localhost上托管的应用程序获取名字,姓氏和电子邮件等详细信息?我是否需要从开发者的页面进行任何设置?
我正在使用这个简单的FB连接
<a href="#" onclick="fb_login();">Connect</a>
Run Code Online (Sandbox Code Playgroud)
window.fbAsyncInit = function(){FB.init({appId:'YOUR_APP_ID',oauth:true,status:true,//检查登录状态cookie:true,//启用cookie以允许服务器访问会话xfbml: true //解析XFBML});
};
function fb_login(){
FB.login(function(response) {
if (response.authResponse) {
console.log('Welcome! Fetching your information.... ');
console.log(response); // dump complete info
access_token = response.authResponse.accessToken; //get access token
user_id = response.authResponse.userID; //get FB UID
FB.api('/me', function(response) {
user_email = response.email; //get user email
console.log(response);
});
} else {
//user hit cancel button
console.log('User cancelled login or did not fully authorize.');
}
}, {
scope: 'email'
});
}
(function() {
var e = document.createElement('script');
e.src = …Run Code Online (Sandbox Code Playgroud) 我在我的laravel php应用程序中启动了一个FB.login(),但Chrome会阻止弹出窗口:
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '{{config('services.facebook.client_id')}}',
xfbml : true,
version : 'v2.5'
});
};
(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/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function facebookLogin(e){
isLoggedIntoFacebook(function(isLoggedIn) {
if (isLoggedIn) {
window.location.href = '{{ route('social.redirect', ['provider' => 'facebook']) }}'
} else {
FB.login(function(response) {
loginUserIntoRegalosPersonales();
}, { scope: ['email', 'user_birthday'] });
FB.Event.subscribe('auth.login', function () {
window.location.href = '{{ route('social.redirect', ['provider' …Run Code Online (Sandbox Code Playgroud) javascript php facebook google-chrome facebook-javascript-sdk
是否有可能为粉丝页的管理员创建一个facebook应用程序,当特定粉丝或粉丝生日时,它们具有在墙上发布生日祝福的功能?
javascript php facebook facebook-javascript-sdk facebook-php-sdk