Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm trying to retrieve some data from the FaceBook graph API. The API URL returns the following string:

access_token=AAABBBB&expires=5173539

The following Python code throws a ValueError: No JSON object could be decoded on the 4th line:

import json
import urllib2
data = urllib2.urlopen(url).read()
jdata = json.loads(data)
print jdata.access_token
share|improve this question
1  
What makes you think the string "access_token=AAABBBB&expires=5173539" is JSON encoded? – S.Lott Feb 14 '12 at 19:39
S. Lott- Nothing - I don't know what what I was thinking – Yarin Feb 14 '12 at 19:46
Neither do we. Perhaps you should delete this question. – S.Lott Feb 14 '12 at 19:54

closed as not constructive by Yarin, Enrico Pallazzo, RanRag, bgporter, Paul McGuire Feb 14 '12 at 21:15

As it currently stands, this question is not a good fit for our Q&A; format. We expect answers to be supported by facts, references, or specific expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, see the FAQ for guidance.

1 Answer

up vote 2 down vote accepted

If this is the actual body of the API response:

access_token=AAABBBB&expires=5173539

That's not JSON. It's just a query string, much like a GET request, and will need to be parsed in another way.

share|improve this answer
Casey- thank you for pointing out the embarrassingly obvious- my bad – Yarin Feb 14 '12 at 19:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.