If i manage to get a response.session object, can i use it to get the current logged in users username and profile image?
Thanks
FB.api('/me', function(response) {
alert("Name: "+ response.name + "\nFirst name: "+ response.first_name + "ID: "+response.id);
var img_link = "http://graph.facebook.com/"+response.id+"/picture"
});
More info here:
http://developers.facebook.com/docs/reference/javascript/FB.api/
Additionnaly, you can get more personnal informations about connected user :
FB.api('/me', function(response) {
console.log(response);
});
Hope that helps
Here are the three possible states:
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
// the user is logged in and connected to your
// app, and response.authResponse supplies
// the user’s ID, a valid access token, a signed
// request, and the time the access token
// and signed request each expire
var uid = response.authResponse.userID;
var accessToken = response.authResponse.accessToken;
} else if (response.status === 'not_authorized') {
// the user is logged in to Facebook,
//but not connected to the app
} else {
// the user isn't even logged in to Facebook.
}
});
After, you managed to get response session object, you can do following
var rec="Name : "+response.name+"";
rec +="Link: "+response.link+"";
rec +="Username: "+response.username+"";
rec +="id: "+response.id+"";
rec +="Email: "+response.email+"";
function getPhoto()
{
FB.api('/me/picture?type=normal', function(response) {
var img=response.data.url;
});
For more info you can refer to this manual: https://developers.facebook.com/docs/javascript/reference/FB.api
FB.getLoginStatus(function(response) {
if (response.session) {
//response.session contains what you lokks for
} else {
// user is not connected..
}
如果用户已登录并已授权您的应用程序,您应该能够。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.