Over a million developers have joined DZone.

Download all messages between you and a friend from facebook

·

 

require 'koala' # gem install koala --no-document

# create a facebook app and get access token from here
# https://developers.facebook.com/tools/explorer
# select "read_mailbox" when authenticating
oauth_access_token = 'xxxxxxxxxxxxxxxxxxxxxx'
graph = Koala::Facebook::API.new(oauth_access_token)

# get all latest messages
limit = 10
threads = {}
page = graph.get_connections('me','inbox')
begin
	page.each do |thread| 
		threads[thread["id"]] = thread["to"]["data"].map {|x| x['name']}.join ' - '
	end
end while page = page.next_page and threads.length e
	puts "Error : #{e}, and proceeded to write results to far."
end

File.write '/Users/blaze/Desktop/log.txt', messages.join("\n") 
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}