Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/ruby
- require 'xmlrpc/client'
- $hostname = "spica"
- $blogid = "psteyn"
- $username = "psteyn"
- $password = "password"
- $url = "roller/roller-services/xmlrpc"
- $port = 8080
- class MetaWebLog < XMLRPC::Client
- def newPost
- end
- def editPost
- end
- def newMediaObject(name,type,filename)
- object = {
- 'name' => name,
- 'type' => type,
- 'bits' => XMLRPC::Base64.new(File.read(filename))
- }
- call('metaWeblog.newMediaObject', $blogid, $username, $password, object)
- end
- end
- blog = MetaWebLog.new($hostname,$url,$port)
- blog.newMediaObject("img.jpg", "image/jpeg", "/tmp/img.jpg")
- #<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>
- /usr/lib/ruby/1.8/xmlrpc/client.rb:547:in `do_rpc': HTTP-Error: 400 Invalid URI (RuntimeError)
- from /usr/lib/ruby/1.8/xmlrpc/client.rb:420:in `call2'
- from /usr/lib/ruby/1.8/xmlrpc/client.rb:410:in `call'
- from rb.rb:29:in `newMediaObject'
- from rb.rb:37
Add Comment
Please, Sign In to add comment