-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFriendsID.html
More file actions
33 lines (25 loc) · 1.26 KB
/
FriendsID.html
File metadata and controls
33 lines (25 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<h1>Reading from the Graph API</h1>
<p>Here we'll show you how to make a simple request from the Graph API <code>/me</code> endpoint using the FB.api() SDK function. It'll retrieve your friend's name and id. Make sure you've logged in by clicking the Login button in the top left.</p>
<h2>Using FB.api()</h2>
<div id="results" style="padding-top: 20px">You haven't logged in yet.</div>
<script>
function basicAPIRequest() {
Facebook API to get all friends' id:
FB.api('/me/friends?limit=200', function(response) {
Log.info('API response', response);
document.getElementById('results').innerHTML = '';
var names = JSON.parse(JSON.stringify(response));
for (var i=0; i < names["data"].length; i++) {
document.getElementById('results').innerHTML += JSON.stringify(names["data"][i]["id"]);
}
// document.getElementById('accountInfo').innerHTML += JSON.stringify(response);
});
FB.getLoginStatus(function(response) {
Log.info('Login Status', response);
if (response.status === 'connected') {
basicAPIRequest();
}
});
</script>
<h3>Related Guides</h3>
<p>Read <a href="https://developers.facebook.com/docs/javascript/quickstart/#graphapi">our quickstart to using the JavaScript SDK for Graph API calls</a> for more info.</p>