Skip to content

Instantly share code, notes, and snippets.

@lucasdupin
Created January 31, 2013 20:27
Show Gist options
  • Save lucasdupin/4686145 to your computer and use it in GitHub Desktop.
Save lucasdupin/4686145 to your computer and use it in GitHub Desktop.
Daemon to change a facebook page's cover photo.
require 'net/http'
require 'net/https'
require 'rubygems'
require 'daemons'
PIC_IDS = %w(404626466293247 404626476293246 404626472959913 404626492959911) #Pics to change
PAGE_TOKEN = 'TOKEN_HERE'
PAGE_ID = 'PAGE_ID_HERE'
uri = URI("https://graph.facebook.com/#{PAGE_ID}")
Daemons.run_proc('change_cover.rb') do
counter = 0
loop do
https = Net::HTTP.new(uri.host,uri.port)
https.use_ssl = true
req = Net::HTTP::Post.new(uri.path)
req.set_form_data :cover => PIC_IDS[(counter % PIC_IDS.size)], :access_token => PAGE_TOKEN, :no_feed_story => true
res = https.request(req)
puts "Response: #{res.body}"
sleep 20
counter += 1
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment