Created
March 18, 2014 16:01
-
-
Save emad-elsaid/9623076 to your computer and use it in GitHub Desktop.
get facebook friends data and save them as json file
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
#!/usr/bin/env ruby | |
require 'koala' # gem install koala --no-document | |
require 'json' | |
# create a facebook app and get access token from here | |
# https://developers.facebook.com/tools/explorer | |
# select "user_friends" when authenticating | |
oauth_access_token = 'xxxxxxxxxxxxxxxx' | |
graph = Koala::Facebook::API.new(oauth_access_token) | |
fields = 'bio,name,birthday,first_name,last_name,gender,hometown,relationship_status,username,website,languages' | |
friends = [] | |
# getting groups of interest | |
page = graph.get_connections("me", "friends/?fields=#{fields}") | |
begin | |
friends += page | |
end while page = page.next_page | |
# write data to file as json | |
File.write 'friends.json', friends.to_json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment