Skip to content

Instantly share code, notes, and snippets.

@lamp
Created February 9, 2011 11:38
Show Gist options
  • Select an option

  • Save lamp/818345 to your computer and use it in GitHub Desktop.

Select an option

Save lamp/818345 to your computer and use it in GitHub Desktop.
#henryskneethingy
require "rubygems"
require "net/http"
require "net/https"
require "json"
require "open-uri"
$app_id = "xxxxx"
$app_secret = "xxxxx"
$access_code = "xxxxx"
$access_token = "xxxxxx"
begin
f = File.open("timestamp.txt", "r")
timestamp = f.read.to_i
rescue
timestamp = Time.now.to_i
end
uri = URI.parse(URI.encode("https://graph.facebook.com/dallow1/feed?access_token=#{$access_token}"))
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true if uri.scheme == "https"
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
response = http.get("#{uri.path}?#{uri.query}")
feed = JSON.parse(response.body)
feed['data'].each do |message|
if message['message'] and message['message'].include? "knee" and timestamp < Time.parse(message['created_time']).to_i
arr = message["message"].split('.')
title = arr.shift.capitalize
msg = arr.map { |i| i.capitalize }.join(".")
res = Net::HTTP.post_form(URI.parse('http://www.tumblr.com/api/write'),
{'email' => 'xxxxx', 'password' => 'xxxxxx', "type" => "regular", "title" => title, "body" => msg, "group" => "henryskneeprogress.tumblr.com"})
p "posted"
end
end
f = File.open("timestamp.txt", "w+")
f.puts Time.now.to_i.to_s
f.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment