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

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


#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| }

mp3bits = Base64.encode64(mp3_string)

Make an object to represent the XML-RPC server.

server = “”, “/RPC2”)

Call the remote server and get our result

result =“twittergram.newPost”, username, password,

puts “#{result}”

Never mind folks. I found working sample code here: