Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

gotwalt commented Aug 17, 2010

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.