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

···

----
#!/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}"

Never mind folks. I found working sample code here:

···

On Jun 28, 10:08 am, phildog <phildog.thomp...@gmail.com> wrote:

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