最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Check if Facebook user exists using Javascript - Stack Overflow

programmeradmin0浏览0评论

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:

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.

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./#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.

Share Improve this question edited Feb 8, 2014 at 0:46 Kara 6,22616 gold badges53 silver badges58 bronze badges asked Oct 26, 2013 at 14:09 nch7nch7 1102 silver badges7 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

Try this code by using jQuery.

var pictureUrl= "https://graph.facebook./" + userId + "/picture";
$.ajax({
    url : pictureUrl,
    statusCode: {
        200: function() {
            alert("user exist");
        },
        404: function() {
            alert( "user not exist" );
        }
    }
});
发布评论

评论列表(0)

  1. 暂无评论