Forum: Ruby need help posting a base64-encoded binary via xml-rpc

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
5f120f69de8a3c851ce7e3d94df7e6db?d=identicon&s=25 phildog (Guest)
on 2007-06-28 16:11
(Received via mailing list)
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}"
5f120f69de8a3c851ce7e3d94df7e6db?d=identicon&s=25 phildog (Guest)
on 2007-06-28 16:36
(Received via mailing list)
Never mind folks. I found working sample code here:
This topic is locked and can not be replied to.