Guest User

Untitled

a guest
Mar 12th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. #!/usr/bin/ruby
  2.  
  3. require 'xmlrpc/client'
  4.  
  5. $hostname = "spica"
  6. $blogid = "psteyn"
  7. $username = "psteyn"
  8. $password = "password"
  9. $url = "roller/roller-services/xmlrpc"
  10. $port = 8080
  11.  
  12.  
  13. class MetaWebLog < XMLRPC::Client
  14.  
  15. def newPost
  16. end
  17.  
  18. def editPost
  19. end
  20.  
  21. def newMediaObject(name,type,filename)
  22.  
  23. object = {
  24. 'name' => name,
  25. 'type' => type,
  26. 'bits' => XMLRPC::Base64.new(File.read(filename))
  27. }
  28.  
  29. call('metaWeblog.newMediaObject', $blogid, $username, $password, object)
  30.  
  31. end
  32.  
  33. end
  34.  
  35. blog = MetaWebLog.new($hostname,$url,$port)
  36.  
  37. blog.newMediaObject("img.jpg", "image/jpeg", "/tmp/img.jpg")
  38.  
  39.  
  40. #<MetaWebLog:0xb7c3550c @path="roller/roller-services/xmlrpc", @password=nil, @http_header_extra=nil, @use_ssl=false, @host="spica", @user=nil, @auth=nil, @proxy_port=nil, @cookie=nil, @create=#<XMLRPC::Create:0xb7c352a0 @writer=#<XMLRPC::XMLWriter::Simple:0xb7c352c8>>, @port=8080, @http=#<Net::HTTP spica:8080 open=false>, @proxy_host=nil, @http_last_response=#<Net::HTTPBadRequest 400 Invalid URI readbody=true>, @parser=nil, @timeout=30>
  41. /usr/lib/ruby/1.8/xmlrpc/client.rb:547:in `do_rpc': HTTP-Error: 400 Invalid URI (RuntimeError)
  42. from /usr/lib/ruby/1.8/xmlrpc/client.rb:420:in `call2'
  43. from /usr/lib/ruby/1.8/xmlrpc/client.rb:410:in `call'
  44. from rb.rb:29:in `newMediaObject'
  45. from rb.rb:37
Add Comment
Please, Sign In to add comment