Reputation: 53
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
Upvotes: 5
Views: 23646
Reputation: 969
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
Upvotes: 0
Reputation: 1934
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.
}
});
Source: https://developers.facebook.com/blog/post/525/
Upvotes: 1
Reputation: 40401
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/
Upvotes: 16
Reputation: 86
Additionnaly, you can get more personnal informations about connected user :
FB.api('/me', function(response) {
console.log(response);
});
Hope that helps
Upvotes: 3
Reputation: 160
If the user is logged in and has authorized your application, you should be able to.
Upvotes: 0
Reputation: 86
FB.getLoginStatus(function(response) {
if (response.session) {
//response.session contains what you lokks for
} else {
// user is not connected..
}
Upvotes: 0