Get All your Facebook Checkins and print out location lang/long
this is a simple script to get all your facebook checkins and print out the location name and lat/long, this will be useful if you wanted to make a map of the locations you have visited in your life, just like facebook does on your profile.
Gist : https://gist.github.com/9912391
#!/usr/bin/env ruby
# Author : Emad Elsaid (https://github.com/blazeeboy)
require 'koala' # gem install koala --no-document
# create a facebook app and get access token from here
# https://developers.facebook.com/tools/explorer
# select "user_status", "friends_status", "user_checkins" when authenticating
oauth_access_token = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
graph = Koala::Facebook::API.new(oauth_access_token)
places = []
page = graph.get_connections('me', 'checkins')
begin
places += page.map {|p| p['place']}
end while page = page.next_page
places.each do |place|
unless place['location'].is_a? String
puts "#{place['name']} lat:#{place['location']['latitude']} long:#{place['location']['longitude']}"
else
puts "#{place['name']} location:#{place['location']}"
end
end
Written by Emad Elsaid
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Related Tags
#ruby
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#