Created
February 17, 2016 07:43
-
-
Save roman-karpovich/5d139496821876a2bf85 to your computer and use it in GitHub Desktop.
comparing friends got from `taggable_friends` with `friends`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FB.getLoginStatus(function (response) { | |
if (response.status === 'connected') { | |
console.log('already logged into facebook'); | |
FB.api('/', 'POST', { | |
batch:[ | |
{method: 'GET', relative_url: '/me?fields=birthday,name,email,gender,age_range,first_name,last_name&locale=en_US'}, | |
{method: 'GET', relative_url: '/me/taggable_friends?fields=name,first_name,last_name,picture.width(400).height(400)&locale=en_US'}, | |
{method: 'GET', relative_url: '/me/friends?limit=0&locale=en_US'} | |
], | |
include_headers: false | |
}, function(response_array){ | |
if (response_array && !response_array.error) { | |
var my_response = JSON.parse(response_array[0].body); | |
if (my_response && ! my_response.error) { | |
console.log('I\'m ' + my_response.name); | |
console.log('My fbid is ' + FB.getUserID()); | |
} | |
else { | |
console.log('my data is unavailable'); | |
} | |
var taggable_friends_response = JSON.parse(response_array[1].body); | |
if (taggable_friends_response && ! taggable_friends_response.error) { | |
console.log('I\'ve got ' + taggable_friends_response.data.length + ' friends in taggable_friends.'); | |
var friends_arr = []; | |
for (var i = 0; i < taggable_friends_response.data.length; i++) { | |
friends_arr.push(taggable_friends_response.data[i].name) | |
} | |
console.log('They are: '); | |
console.log(friends_arr); | |
} | |
else { | |
console.log('friends data is unavailable'); | |
} | |
var friends_response = JSON.parse(response_array[2].body); | |
if (friends_response && ! friends_response.error) { | |
console.log('My real friends count is ' + friends_response.summary.total_count); | |
} | |
else { | |
console.log('friends data is unavailable'); | |
} | |
} | |
else{ | |
console.log('batch request failed'); | |
} | |
}); | |
} | |
else { | |
console.log('user is not logged in.') | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment