Created
May 26, 2014 23:06
-
-
Save adamloving/bd86745c102f67ea1cab to your computer and use it in GitHub Desktop.
Post several links to a Facebookpage
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 | |
# foreman run script/social/auto-fbpost.rb data/crawl-data.json | |
# To get page access token, go to graph explorer, get user token with manage_pages and publish_actions permission, | |
# then request /{userId}/accounts | |
require 'koala' | |
require 'json' | |
graph = Koala::Facebook::API.new(ENV['FB_PAGE_ACCESS_TOKEN']) | |
urls = JSON.parse(File.open(ARGV.first).read) | |
# todo: add hashtags | |
for url in urls[2..100] | |
text = url['description'] || url['title'] | |
graph.put_object(ENV['FB_PAGE_ID'], 'feed', :message => text, :link => url['url']) | |
puts "Posted: #{text}" | |
Kernel.sleep(10) | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment