Skip to content

Instantly share code, notes, and snippets.

@chrismcclelland
Created January 6, 2009 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chrismcclelland/43870 to your computer and use it in GitHub Desktop.
Save chrismcclelland/43870 to your computer and use it in GitHub Desktop.
# requires curb gem (http://curb.rubyforge.org/)
# I used matthooks’ vimeo gem to get the required token, sig and ticket. http://github.com/matthooks/vimeo/tree/master
# (flickraw has an alternative method of doing a http POST in the source using net/http which could be adapted for vimeo, avoiding the use of this curb gem)
# connect to Vimeo
VIMEO_API_KEY = "your api key"
VIMEO_SHARED_SECRET = "your shared secret"
v = VimeoAdvanced.new(VIMEO_API_KEY, VIMEO_SHARED_SECRET)
v.login_link("write") # connect the user to your app
token_xml = v.get_token(frob) # using the fetched :frob from the callback URL
xml = REXML::Document.new(token_xml)
token = xml.root.elements[1].elements[1].text # parse the token from the XML response
v.check_token(token)
# --- upload part.
# 1. Get an Upload Ticket
ticket_xml = v.video_get_upload_ticket(token)
xml = REXML::Document.new(ticket_xml)
ticket = xml.root.elements[1].attributes["id"]
sig = v.upload_sig(ticket, token)
# 2. Post the Video uses CURB
c = Curl::Easy.new("http://vimeo.com/services/upload/")
c.multipart_form_post = true
c.http_post(
Curl::PostField.content('api_key', VIMEO_API_KEY),
Curl::PostField.content('auth_token', token),
Curl::PostField.content('api_sig', sig),
Curl::PostField.content('ticket_id', ticket),
Curl::PostField.file("video.mov", sample_video))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment