Skip to content

Instantly share code, notes, and snippets.

@gotwalt
Created August 17, 2010 05:33
Show Gist options
  • Save gotwalt/528586 to your computer and use it in GitHub Desktop.
Save gotwalt/528586 to your computer and use it in GitHub Desktop.
Posting to twitpic in Ruby using oauth echo
require "nestful"
require "roauth"
def upload(path_to_file)
twitpic_key = "my_twitpic_api_key"
oauth_url = "https://api.twitter.com/1/account/verify_credentials.json"
oauth = {
:access_key => "account_access_key",
:access_secret => "account_access_secret",
:consumer_key => "application_key",
:consumer_secret => "application_secret"
}
oauth_result = ::ROAuth.header(oauth, oauth_url, {})
headers = {
"X-Auth-Service-Provider" => oauth_url,
"X-Verify-Credentials-Authorization" => oauth_result
}
params = {
:media => File.open(path_to_file),
:key => twitpic_key
}
result = Nestful.post(endpoint_url, :format => :multipart, :headers => headers, :params => params)
JSON.parse(result)
end
@gotwalt
Copy link
Author

gotwalt commented Aug 17, 2010

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment