Get string value from http response with Mechanize

Posted by Gearóid on Stack Overflow See other posts from Stack Overflow or by Gearóid
Published on 2010-06-08T20:00:50Z Indexed on 2010/06/08 20:02 UTC
Read the original article Hit count: 242

Filed under:
|
|

Hi,

I'm currently integrating facebook into my current app and I've succeeded in retrieving the access_token using the following code:

url="#{url}?#{client_id}&#{client_secret}&#{code}&#{redirect_uri}&type=client_cred"

agent = Mechanize.new

page = agent.get(url)

The page object above has a body which contains text something along the lines of

access_token=XXXXX

I just want to pull out the access_token value. I can get the entire string simply by writing:

page.body

But I was wondering is there a way to get the access_token value without resorting to regular expressions etc?

Thanks.

© Stack Overflow or respective owner

Related posts about ruby

Related posts about rubygems