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?
As it turns out, the best way I could find to do this was:
token = page.body.split(/access_token=/)[1]