Reputation: 110
I'm looking for a way to check if there is a Facebook user with a particular ID.
I know that there is an Graph API which can return Facebook user's profile picture for given ID, it works like this: https://graph.facebook.com/#USER_ID_HERE#/picture
and I see that if I enter ID that doesn't exists it returns error, however I'm still very new to JavaScript so I don't really know how to "read" that error message.
Upvotes: 2
Views: 3394
Reputation: 261
Try this code by using jQuery.
var pictureUrl= "https://graph.facebook.com/" + userId + "/picture";
$.ajax({
url : pictureUrl,
statusCode: {
200: function() {
alert("user exist");
},
404: function() {
alert( "user not exist" );
}
}
});
Upvotes: 7