Skip to content

Instantly share code, notes, and snippets.

@timhaines
Forked from gotwalt/gist:528586
Created August 24, 2010 11:36
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 timhaines/547403 to your computer and use it in GitHub Desktop.
Save timhaines/547403 to your computer and use it in GitHub Desktop.
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
@crm114
Copy link

crm114 commented Oct 12, 2010

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