Open arjunblj opened 9 years ago
Does the authenticated user have any reviews? If not, the API might be returning something unexpected.
Yes, the user has many reviews, so I'm trying to figure out what the issue is. (side note: for contributers, how do I access apikey.py
? I've tried running the command in the Travis config file but it's not working.)
apikey.py stores API developer key and secret. To be specific it has
key = 'foo' secret = 'bar' oauth_access_token = 'baz' oauth_access_token_secret = 'qux'
The last two are OAuth key and secrets that are used in client.authenticate function.
You can create the file (under goodreads/goodreads directory) to run tests with nose.
Hi Sefa, Actually, I'm having the same problem as Arjun. I made sure that the key,secret pair is different from oauth token, secret pair. I'm running your package in Win7-64bit. When I try to run this code, it gives me the same error. res = gc.session.get('shelf/list.xml', params={'page':'1', 'user_id':'1'})
Any hint will be helpful, Thank you,
Same here, when I try to do reviews = user.reviews()
I get the following error:
Traceback (most recent call last):
File "/Users/Kars/Projects/goodreads-weighted-average-rating/list.py", line 12, in <module>
reviews = user.reviews()
File "/Users/Kars/Virtualenvs/goodreads-weighted-average-rating/lib/python2.7/site-packages/goodreads/user.py", line 66, in reviews
{'v': 2, 'id': self.gid, 'page': page})
File "/Users/Kars/Virtualenvs/goodreads-weighted-average-rating/lib/python2.7/site-packages/goodreads/session.py", line 54, in get
return xmltodict.parse(resp.content)['GoodreadsResponse']
File "/Users/Kars/Virtualenvs/goodreads-weighted-average-rating/lib/python2.7/site-packages/xmltodict.py", line 311, in parse
parser.Parse(xml_input, True)
xml.parsers.expat.ExpatError: syntax error: line 1, column 0
[Finished in 2.1s with exit code 1]
A fix would be most welcome.
Following up on my previous comment. I poked around a little bit more and got this to work:
res = gc.session.get('review/list?v=2', params={'id':user_id, 'shelf':'to-read', 'key':developer_key})
My guess is it has something to do with the fact that user.reviews()
uses self._client.session.get
whereas user.shelves()
(which does work for me) uses self._client.request
. Something about a developer key not getting passed or something? I don't have a session? I don't know. Kind of out of my depth here.
Okay, so if I change your code like so (explicitly passing the client_key
), it works:
def reviews(self, page=1):
"""Get all books and reviews on user's shelves"""
resp = self._client.session.get("/review/list.xml",
{'v': 2, 'id': self.gid, 'page': page, 'key': self._client.client_key})
return [review.GoodreadsReview(r) for r in resp['reviews']['review']]
No idea if this is an acceptable fix, just thought I'd share.
Hey man – quick q. When I try to access reviews (after authentication), this breaks (error below). I wasn't able to figure out where it was breaking at a quick glance but if you have any theories, I'd be happy to fix it and write some more thorough tests for it.