我已经将facebook graph api v2.0用于我的.net应用程序
我插入了以下javascript代码:
(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#version=v2.0&xfbml=1&appId=" + AppId;
fjs.parentNode.insertBefore(js, fjs);
} (document, 'script', 'facebook-jssdk'));
对于fb登录,我使用了以下代码:
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
myMethod();
} else {
//user hit cancel button
console.log('User cancelled login or did not fully authorize.');
return false;
}
}, {
scope: 'publish_stream,email'
});
function myMethod()
{
FB.api('/me', function (response) {
uid = response.id;
username = response.username;
email = response.email;
gender = response.gender;
fullname = response.name;
firstname = response.first_name;
lastname = response.last_name;
link = response.link;
//then i perform other operations
});
}
此代码确实带来了用于登录的fb弹出窗口,但问题很多时候弹出窗口没有关闭 而且我没有得到api的任何回复。 这个东西在IE9中变得更糟,我为它编写了元标记,但仍然没用。
<meta http-equiv="X-UA-Compatible" value="IE=9">
有没有人有任何解决方案。它太令人沮丧了,我尝试了很多东西但是没有用。