Debug Blitline Postback with localhost
Set up a Sinatra Callback Listener
First we'll create a trivial sinatra listner to listen for the Blitline callback:
gem install sinatra
Then we'll make the listener:
sudo nano blitline_listener.rb
Paste the following into the file:
require 'sinatra'
post '/callback' do
puts "RESULTS->" + params.inspect
end
Hit ctrl-O and Y and Enter to save
Now start the ruby server using the following:
ruby blitline_listener.rb
This will start the sinatra listener. You will need to leave this server running, so open up a new console window and continue with the instructions below.
Route Blitline Callback to Your Localhost Machine:
We will create a localhost SSH tunnel so that Blitline server can talk to your localhost machine.
gem install localtunnel
(There are more secure alternatives to this, we recommend ForwardHQ , but localtunnel is free)
localtunnel -k ~/.ssh/id_rsa.pub 4567
You will get some output like:
This localtunnel service is brought to you by Twilio.
Port 4567 is now publicly accessible from http://3un3.localtunnel.com ...
It is important to note the url identified by this output. It will be different every time. Notice that in the example above, the url is "http://3un3.localtunnel.com" This url will be used in the next section.
Leave this localhost tunnel running and open a new console window, and continue with the instructions below...
Call Blitline with a Postback URL:
You can call Blitline by simply using a curl call.
The APPLICATIONID and the LOCALTUNNEL_URL below need to be replaced with your Blitline Application ID and the url determined in the previous section.
curl 'http://api.blitline.com/job' -d json='{ "application_id": "<APPLICATION_ID>", "postback_url": "<LOCAL_TUNNEL_URL>/callback","src" : "http://www.google.com/logos/2011/yokoyama11-hp.jpg", "functions" : [ {"name": "blur", "params" : {"radius" : 0.0, "sigma" : 2.0}, "save" : { "image_identifier" : "MY_CLIENT_ID" }} ]}'
Once you copy and past that curl command into a console, the sinatra server we started in the first section should output the results of the callback from Blitline.
This output should look something like:
{"results"=>"{\"originalmeta\":{\"width\":421,\"height\":163},\"images\":[{\"imageidentifier\":\"MYCLIENTID\",\"s3url\":\"http://s3.amazonaws.com/blitline/2012112319/20/5SVBt56phqNtHarXvlyUSZA.jpg\",\"meta\":{\"width\":421,\"height\":163}}],\"jobid\":\"2_5dwX1cNQP97byPNb57K4g\"}"}
This is the JSON returned from Blitline after it has completed processing your image.
Written by Blitline Developers
Related protips
2 Responses
Thanks, I wasn't even aware of Bitline
Check https://ngrok.com/