Open ghost opened 9 years ago
I have also tried out the mutual_friends method in graph explorer, and got similar errors:
https://developers.facebook.com/tools/explorer/?method=GET&path=me%2Fmutualfriends&version=v2.2
{ "error": { "message": "(#12) user/mutual_friends is deprecated for versions v2.0 and higher", "type": "OAuthException", "code": 12 } }
Ramos - Sorry about that. Earlier this year, Facebook released version 2 of their Graph API, and it tightened up the ability of developers to get mutual friendships (as indicated by the error message in your latest response.) I've been a little unsure how whether to try and find a creative way to salvage this example or replace it with something else entirely.
If you're interested in graphical analysis, definitely take a look at the chapter on GitHub. It provides a rather extensive introduction that I hope you'll find helpful.
On Wed, Nov 26, 2014 at 11:38 AM, Ramos notifications@github.com wrote:
I have also tried out the mutual_friends method in graph explorer, and got similar errors:
https://developers.facebook.com/tools/explorer/?method=GET&path=me%2Fmutualfriends&version=v2.2
{ "error": { "message": "(#12 https://github.com/ptwobrussell/Mining-the-Social-Web-2nd-Edition/issues/12) user/mutual_friends is deprecated for versions v2.0 and higher", "type": "OAuthException", "code": 12 } }
— Reply to this email directly or view it on GitHub https://github.com/ptwobrussell/Mining-the-Social-Web-2nd-Edition/issues/235#issuecomment-64682794 .
Hi Matthew,
Thanks so much for the prompt response! Awesome, I will keep going throughout the book then until reaching to GitHub! But if by any chance you come up with any new examples for Facebook please do keep us posted!
Much appreciated again! Cheers Ramos
@ptwobrussell do you have any writeup saying that they have blocked the API?
Hi Guys,
I am trying out the Chapter 2 FB Mining and I have encountered issues when trying out example 13 for developing the graph of mutual friendships.
I can successfully retrieve the friends list for the first part of the code:
import networkx as nx # pip install networkx import requests # pip install requests
friends = [ (friend['id'], friend['name'],)
for friend in g.get_connections('me', 'friends')['data'] ]
But for the second part, not so lucky:
url = 'https://graph.facebook.com/me/mutualfriends/%s?access_token=%s'
mutual_friends = {}
This loop spawns a separate request for each iteration, so
it may take a while. Optimization with a thread pool or similar
technique would be possible.
In this for loop, two variables (friend_id, friend_name) will be used out of the friends list.
for friend_id, friend_name in friends: r = requests.get(url % (friend_id, ACCESS_TOKEN,) ) # This will return the mutual friends between ego (based on access token) and friend_id print r.content print print '============================================================================ NEW PERSON' print response_data = json.loads(r.content)['data'] mutual_friends[friend_name] = [ data['name'] for data in response_data ]
print mutual_friends
I have got the results like this:
KeyError Traceback (most recent call last)