Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First Initialize FB Javascript SDK as following.</p> <pre><code>&lt;div id="fb-root"&gt;&lt;/div&gt; &lt;script&gt; window.fbAsyncInit = function() { // init the FB JS SDK FB.init({ appId : 'YOUR_APP_ID', // App ID from the App Dashboard channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File for x-domain communication status : true, // check the login status upon init? cookie : true, // set sessions cookies to allow your server to access the session? xfbml : true // parse XFBML tags on this page? }); // Additional initialization code such as adding Event Listeners goes here }; // Load the SDK's source Asynchronously (function(d){ var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; if (d.getElementById(id)) {return;} js = d.createElement('script'); js.id = id; js.async = true; js.src = "//connect.facebook.net/en_US/all.js"; ref.parentNode.insertBefore(js, ref); }(document)); &lt;/script&gt; </code></pre> <p>The above code will initialize your FB SDK. Now in JavaScript write following function. Refer <a href="https://developers.facebook.com/docs/reference/javascript/FB.login/" rel="nofollow">this document</a> for more details.</p> <pre><code>function initiateFB Login() { FB.login(function(response) { if (response.authResponse) { //Login Success if you want you can initiate request for friend list here only. FB.api('/me/friends/fields=id,username', function(resp) { /// Process the resp over here. This resp will be JSON response of friend request } ); } else { console.log('User cancelled login or did not fully authorize.'); } }); } </code></pre> <p>You can get the username i.e. FB User Name. Below is the request for that.</p> <pre><code>me/friends?fields=id,username </code></pre> <p>This request will give you a JSON response of following format. </p> <pre><code>{ "data": [ { "id": "FB_ID", "username": "FB_USER_NAME" }, { "id": "FB_ID", "username": "FB_USER_NAME" } ] } </code></pre> <p>You can parse this and get the username.</p> <p>Hope this helps.</p> <p>Thanks</p> <p>Kaushik</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload