Skip to content
This repository has been archived by the owner on May 22, 2019. It is now read-only.

Reviews bug #2

Open
arjunblj opened this issue Apr 15, 2015 · 7 comments
Open

Reviews bug #2

arjunblj opened this issue Apr 15, 2015 · 7 comments
Labels

Comments

@arjunblj
Copy link

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.

screenshot 2015-04-15 15 38 18

@sefakilic
Copy link
Owner

Does the authenticated user have any reviews? If not, the API might be returning something unexpected.

@arjunblj
Copy link
Author

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.)

@sefakilic
Copy link
Owner

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.

@sefakilic sefakilic added the bug label Apr 19, 2015
@nasimsonboli
Copy link

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'})
error

Any hint will be helpful,
Thank you,

@karsalfrink
Copy link

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.

@karsalfrink
Copy link

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.

@karsalfrink
Copy link

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants