Ente Facebook Analytics Part 3: Get Facebook User ID and Locale

0
SHARES

Through this part by part preparation of ente Facebook Analytics, I am trying to help you understand facebook SDK and API. Today we will know how to obtain the userid and locale of a facebook user using FB.api() from Javascript SDK. This is a straight approach without any complications.

Facebook Userid and Locale

Userid and locale are public information of an account. So we do not need an access token to obtain these values. For example, just visit https://graph.facebook.com/reachjoby to find my details. Our job is to extract needed userid and locale and display it.

Here goes the FB.api code which execute the graph api link for a specified userid and locale. Then assign the value to HTML DOM using jQuery.

FB.api('/'+userid,function(response){
    $('#facebook-user-id').html(response.id);
    $('#facebook-user-locale').html(response.locale);
});
Tags:

About Joby Joseph

Author of jobyj.in. I do a lot of research on web, APIs and social networks. Codes are mainly tried on PHP, jQuery, MySQL. Please support this blog by your facebook likes, twitter follow and RSS Subscribtion. Read more Google+