Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > need help posting a base64-encoded binary via xml-rpc

Reply
Thread Tools

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

 
 
phildog
Guest
Posts: n/a
 
      06-28-2007
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}"

 
Reply With Quote
 
 
 
 
phildog
Guest
Posts: n/a
 
      06-28-2007
Never mind folks. I found working sample code here:
http://dotnet.org.za/armand/archive/...ttergrams.aspx

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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
URL Posting Fails in Medium Trust (3rd time posting this w/ zero replies so far) AmitKu ASP .Net 7 01-08-2007 07:31 PM
CROSS-POSTING, OR MULTI-POSTING, OR NEITHER? Colin D Digital Photography 56 03-08-2006 08:31 PM
[OT] : Top Posting vs Bottom Posting Wayne Wastier Windows 64bit 7 07-17-2005 03:57 PM
Top Posting vs. Bottom Posting scaredkitty Computer Support 37 04-06-2005 12:27 AM
Everytime I hover cursro over a posting, it crosses out with red mark on it.. on every posting alanb ASP .Net 2 04-23-2004 02:23 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57