Search code examples
javascript.netfacebook

How do I get Facebook id


I am building a rss based web-plugin to collect feeds from social media. At the moment the user have to enter the Facebook Id manually that they want to get the feed from.

I found this site http://findmyfacebookid.com/ which does exactly what I want. If I can integrate something similar in my configuration part of the plugin it would be so much smoother user experience.

All help is appreciated.


Solution

  • You can use an ajax call to get a user's facebook id :

    var name = 'zuck';
    $.getJSON('https://graph.facebook.com/' + name, {
      format: "json"
    }).done(function(data) {
      $('#output').html(data.id); // FB Id of his founder
    })
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    Id of Mark Zuckerberg :
    <div id="output"></div>