DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Emad has posted 58 posts at DZone. View Full User Profile

Print all your facebok liked pages names, URLs and when did you like it

03.22.2014
| 1126 views |
  • submit to reddit
#!/usr/bin/env ruby
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_likes" when authenticating
oauth_access_token = 'xxxxxxxxxxxxxxxxxxxxxxxx'
graph = Koala::Facebook::API.new(oauth_access_token)

# get all likes
likes = []
page = graph.get_connections('me','likes')
begin
	likes += page
end while page = page.next_page


# print them all then print total likes
likes.each do |l|
	puts "#{l['name']} - http://www.facebook.com/#{l['id']} - #{l['created_time']}"
end
puts "Total likes : #{likes.length}"