Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
55 lines (43 sloc) 1.5 KB
require 'rubygems'
require 'sinatra'
require 'curb'
require 'yaml'
set :users, YAML::load_file('posterous.yaml')
get '/' do
haml :index
post '/upload/4367803575802/:apikey' do
# Get user's posterous details
apikey = params[:apikey]
user = settings.users[apikey]
# receive mp3 recording from Tropo
file = params[:filename][:tempfile]
filepath = if file.is_a? String
filepath ||= file.path
# rename the file
date =
new_file = File.join(File.dirname(filepath), "#{date.to_s}.mp3")
File.rename filepath, new_file
# upload to posterous
posterous_params = user.merge({'title' => "Podcast #{date.to_s}", 'autopost' => '1',
'source' => 'phone2post',
'sourceLink' => '',
'tags' => 'podcast'})
post_data = {|k, v| Curl::PostField.content(k, v)}
post_data << Curl::PostField.file('media', new_file)
c ='')
c.userpwd = "#{user['username']}:#{user['password']}"
c.multipart_form_post = true
puts c.body_str
enable :inline_templates
@@ layout
= yield
@@ index
%h1 Phone 2 Post
A small application which allows users to record podcasts over the phone and send them to Posterous &mdash; by
%a(href="") Jamie Lawrence.
Something went wrong with that request. Please try again.