Archived from the Transloadit support forum. Originally posted on February 18, 2011; details may be outdated, see our docs for current behavior. Original thread
I’m having a little trouble getting the /http/import robot to work using the REST API. Can anybody spot the problem below?
require 'rubygems'
require 'openssl'
require 'json'
require 'net/http'
auth_key = 'XXXX'
auth_secret = 'XXXX'
image_url = 'http://transloadit.com/img/robots/http-import.jpg'
params = JSON.generate({:auth => {
:expires => Time.now.utc.strftime('%Y/%m/%d %H:%M:%S+00:00'),
:key => auth_key,
:robot => "/http/import",
:url => image_url
}})
digest = OpenSSL::Digest::Digest.new('sha1')
signature = OpenSSL::HMAC.hexdigest(digest, auth_secret, params)
http = Net::HTTP.new("api2.transloadit.com")
request = Net::HTTP::Post.new("/?signature=#{ signature }")
request.set_form_data( { :params => params })
response = http.request( request )
The request goes through, but all I get back is an ‘OK’. I doubt I’m posting to the right place or with the right params.