Check if Facebook user exists using Javascript - Stack Overflow

I'm looking for a way to check if there is a Facebook user with a particular ID.I know that there

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" );
        }
    }
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745253039a4618790.html

相关推荐

  • Check if Facebook user exists using Javascript - Stack Overflow

    I'm looking for a way to check if there is a Facebook user with a particular ID.I know that there

    5小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信