Visit a url programatically

hi all,

i have the code below;

require ‘rexml/document’
require ‘open-uri’
open(‘http://api.evdb.com/rest/users/login?app_key=ct2hJqTCg4XLCP5h’)
{ |f|
$res = REXML::Document.new(f.read)
}

the xml data that is read is;

<?xml version="1.0" encoding="UTF-8"?> 6984053721 Please supply a user authentication response using the nonce provided.

QUESTIONS

  1. how do i get the value of nonce (i.e. 6984053721 )

  2. is there another way of visiting the url “http://api.evdb.com/rest/
    users/login?app_key=ct2hJqTCg4XLCP5h”
    without using open-uri as in above

thoughts??

On 2010-05-10 11:24:46 -0400, kevid said:

thoughts??

I don’t mean to be rude, but you should read the corresponding API
documentation.

http://api.evdb.com/docs/auth

The way you access a URL is good, the problem is about that specific
one.
The link I provide should direct you in the right direction.
You also might want to check the mailing list, there is bound to be good
info
on whatever it is that you seek.

Have a good day!

I’m not sure specifically what you’re trying to do. If you’re trying to
interact with a web sit, maybe Mechanize would be a better option of
something to use?

http://mechanize.rubyforge.org/mechanize/

-David

kevid [email protected] writes:

To get the nonce node, just use an xpath:

require ‘rexml/document’
require ‘open-uri’
nonce = nil

open(‘http://api.evdb.com/rest/users/login?app_key=ct2hJqTCg4XLCP5h’)
{ |f|
doc = REXML::Document.new(f.read)
nonce = XPath.first(doc, “/error/nonce”)
}