Ruby confluence4r examples

I cannot find where to download the confluence4r gem and it doesn't work when I do:

gem install confluence4r

I downloaded one here: http://confluence.atlassian.com/display/DISC/Confluence4r

I can login

server = Confluence::RPC.new("http://wiki/")
server.login("username","password")

but once I do anything else it fails

server.getSpace("key")

but wait.. I do it a 2nd time and it works...

server.getSpace("key")

{"name"=>"key example", "homePage"=>"235325", "url"=>"http://wiki/display/key", "type"=>"global", "description"=>"description example", "key"=>"key"}

Here's the error I receive on the first try before making it work on the 2nd try:

EOFError: end of file reached

from /usr/lib/ruby/1.8/net/protocol.rb:135:in sysread' from /usr/lib/ruby/1.8/net/protocol.rb:135:in rbuf_fill' from /usr/lib/ruby/1.8/timeout.rb:62:in timeout' from /usr/lib/ruby/1.8/timeout.rb:93:in timeout' from /usr/lib/ruby/1.8/net/protocol.rb:134:in rbuf_fill' from /usr/lib/ruby/1.8/net/protocol.rb:116:in readuntil' from /usr/lib/ruby/1.8/net/protocol.rb:126:in readline' from /usr/lib/ruby/1.8/net/http.rb:2024:in read_status_line' from /usr/lib/ruby/1.8/net/http.rb:2013:in read_new' from /usr/lib/ruby/1.8/net/http.rb:1050:in request' from /usr/lib/ruby/1.8/net/http.rb:992:in post2' from /usr/lib/ruby/1.8/xmlrpc/client.rb:538:in do_rpc' 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 /usr/lib/ruby/1.8/xmlrpc/client.rb:617:in send' from /usr/lib/ruby/1.8/xmlrpc/client.rb:617:in method_missing' from ./confluence4r.rb:35:in send' from ./confluence4r.rb:35:in method_missing'

Any ideas why I'm getting the error?

EDIT

Okay, I'm using part of this gem instead and it works fine:

gem install confluencer
@api = Confluence::Client.new(:url => "http://wiki")
@api.login("username","password")
user = @api.getUser("username")
pp user

{"name"=>"username",
 "url"=>"http://wiki/display/~username",
 "fullname"=>"Full Name",
 "email"=>"EmailAddress@example.com"}

now the problem is I am unable to add anything, but I can do gets and thats it. It just hangs and I believe continues to do a retry over and over again. Maybe my wiki is broken..

create_user = @api.createUser("username","password","First LastName","Email@example.com")
pp create_user

Hangs at create_user


Okay using just XMLRPC Client now and everything is working

require 'xmlrpc/client'

confluence = XMLRPC::Client.new2("http://wiki/rpc/xmlrpc").proxy("confluence1")
token = confluence.login("username", "password")

user = {
"name" => user_name,
"fullname" => full_name,
"email" => email
}

confluence.addUser(token, user, user_name)

I tested this in confluence 2.8 to 3.4 - wow that was soo much easier!


FYI, using the confluence4r.rb code fails with Confluence v4. The simple fix is to change... @conf = server.proxy("confluence1") TO @conf = server.proxy("confluence2")

The error message is: confluence.rb:38:in rescue in method_missing': java.lang.Exception: com.atlassian.confluence.rpc.RemoteException: Unsupported operation: Wiki formatted content can no longer be retrieved from this API. Please use the version 2 API. The version 2 WSDL is available at: https://wiki.globalrelay. net/rpc/soap-axis/confluenceservice-v2?wsdl. XML-RPC requests should prefixed with "confluence2.". (RuntimeError) from confluence.rb:31:in rescue in method_missing': java.lang.Exception: com.atlassian.confluence.rpc.RemoteException: Unsupported operation: Wiki formatted content can no longer be retrieved from this API. Please use the version 2 API. The version 2 WSDL is available at: https://wiki.globalrelay. net/rpc/soap-axis/confluenceservice-v2?wsdl. XML-RPC requests should prefixed with "confluence2.". (RuntimeError) from confluence.rb:31:in rescue in method_missing': java.lang.Exception: com.atlassian.confluence.rpc.RemoteException: Unsupported operation: Wiki formatted content can no longer be retrieved from this API. Please use the version 2 API. The version 2 WSDL is available at: https://wiki.globalrelay. net/rpc/soap-axis/confluenceservice-v2?wsdl. XML-RPC requests should prefixed with "confluence2.". (RuntimeError) from confluence.rb:31:in method_missing'

链接地址: http://www.djcxy.com/p/38770.html

上一篇: EOFError:文件结尾达到Net :: HTTP的问题

下一篇: Ruby confluence4r的例子