Reputation: 365
I have successfully managed to facilitate facebook users to authenticate to my application using their facebook login by using facebook_sdk.
Now I want to get friends of the person who authenticated my application.
How can I achieve this with facebook_sdk?
Upvotes: 1
Views: 290
Reputation: 9051
Here is jsfiddle showing how you can get list of friends from js: http://jsfiddle.net/R3KF4/2/
Just place your app id and secret at the bottom, and id of fb profile which has authorized that app.
I suggest you to turn on network tab / capture in developer tools in your browser, so you can see what goes over the wire.
It is based on my simple feed getter: https://github.com/goranobradovic/CommonCodeSnippets/blob/master/JS/fbUtils.js
Of course, to properly secure your application, you need to perform first step (get oauth token) from server side code (in php). To be clear, you need to place your app id and secret into this url: "https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id={appId}&client_secret={secret}"
and then perform get request from php to acquire token, and then place it into js as variable, so users opening your page do not see your app id and secret. From js you can then use 'https://graph.facebook.com/'+ userId + '/friends&' + token
to load json with friends.
Upvotes: 1