Skip to content

Instantly share code, notes, and snippets.

@june29
Created November 9, 2008 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save june29/23307 to your computer and use it in GitHub Desktop.
Save june29/23307 to your computer and use it in GitHub Desktop.
cdb_config = Pit.get("couchdb", :require => {
"host" => "CouchDB host",
"port" => "CouchDB port"
})
ps_config = Pit.get("bcphotoshare.com", :require => {
"email" => "your email address",
"password" => "your password"
})
tw_config = Pit.get("twitter.com", :require => {
"username" => "your user name",
"password" => "your password"
})
cdb = CouchDB.new(cdb_config["host"], cdb_config["port"])
latest_uri = "/photoshare/latest_processed_photo/"
latest = cdb.get(latest_uri)
ps = PhotoShare.new(ps_config["email"], ps_config["password"])
photos = ps.my_photo
twitter = Twitter::Base.new(tw_config["username"], tw_config["password"])
photos.each do |photo|
if photo["id"] > latest["photo_id"]
twitter.update %![PhotoShare] #{photo["title"]} #{photo["url"]}!
puts %![PhotoShare] #{photo["title"]} #{photo["url"]}!
cdb.put(latest_uri, {
"photo_id" => photo["id"],
"photo_title" => photo["title"],
"_rev" => latest["_rev"]
})
latest = cdb.get(latest_uri)
sleep 5
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment