need help posting a base64-encoded binary via xml-rpc

P

phildog

Hi folks. I'm trying to post a base64-encoded binary (an mp3 file) via
xml-rpc. But it isn't working. Everything seems to work but the
resulting mp3 won't play in my browser. I think the encoding is
getting garbled somehow, but I'm new to this and can't spot the
problems. Can anyone help?

Code sample below. Thanks!

file: twitogram.rb
----
#!/usr/bin/ruby

#usage: twitogram.rb myfile.mp3

require "xmlrpc/client"
require "base64"

username = 'twitter_user'
password = 'twitter_pass'

#slurp into string
mp3_string = open(ARGV[0], 'rb') { |f| f.read }

mp3bits = Base64.encode64(mp3_string)

# Make an object to represent the XML-RPC server.
server = XMLRPC::Client.new( "rpc.twittergram.com", "/RPC2")

# Call the remote server and get our result
result = server.call("twittergram.newPost", username, password,
mp3bits)

puts "#{result}"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,696
Latest member
BarbraOLog

Latest Threads

Top