[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

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

phildog

6/28/2007 2:09:00 PM

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

1 Answer

phildog

6/28/2007 2:31:00 PM

0

Never mind folks. I found working sample code here:
http://dotnet.org.za/armand/archive/2007/06/26/twitter...

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