Skip to content

Instantly share code, notes, and snippets.

@JangoSteve
Created April 19, 2010 22:04
Show Gist options
  • Save JangoSteve/371710 to your computer and use it in GitHub Desktop.
Save JangoSteve/371710 to your computer and use it in GitHub Desktop.
# Created by Steve Schwartz [1] (for Alfa Jango, LLC [2]) for the Twilk API [3]
# [1] http://github.com/jangosteve
# [2] http://www.alfajango.com
# [3] http://twilk.com
# The latest version of this script may be found at http://gist.github.com/371710
require 'net/http'
require 'rubygems'
require 'json'
collage = {
'screen_name' => 'jangosteve',
'height' => 146,
'width' => 146,
'images' => [
{
'x' => 0,
'y' => 0,
'width' => 73,
'height' => 73
},
{
'x' => 73,
'y' => 0,
'width' => 73,
'height' => 73,
'rotate' => -90
},
{
'x' => 73,
'y' => 73,
'width' => 73,
'height' => 73,
'rotate' => 180
},
{
'x' => 0,
'y' => 73,
'width' => 73,
'height' => 73,
'rotate' => 90
}
]
}
post_request = Net::HTTP::Post.new('/testLayout', initheader = {'Centent-Type' => 'application/json'})
response = Net::HTTP.new('api.twilk.com', 80).start { |http| http.request(post_request, collage.to_json) }
case response
when Net::HTTPSuccess, Net::HTTPRedirection
File.open('twilk_background.jpg', 'wb+') do |f|
f << response.body
end
else
response.error!
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment