Goodreads Developers discussion

170 views
examples / showcase > Android example?

Comments Showing 1-9 of 9 (9 new)    post a comment »
dateUp arrow    newest »

message 1: by Grunthos (last edited Dec 27, 2011 05:15PM) (new)

Grunthos | 60 comments [[Edit: Solved!

Skip to end for resolution. YAGRAC is a good source of sample code]]

Hi,

I have been trying to get oauth updates to work from Android using the 'Scribe' oauth library, but without much luck.

I *can* get the oauth user ID, which I assume means that I am registering OK, but when I try to update reviews using, eg.

http://www.goodreads.com/review/show/...

I just get the review back, no changes are made.

When I try updating a shelf using:

http://www.goodreads.com/user_shelves...

(including permutation with and without '[]' and %5B/D), I get either 'not found' or 'not authorized'.

I'm guessing it is something to do with brackets, but from what I can tell the '[' and ']' in parameter names *are* being encoded correctly.

Any help, suggestions, or examples would be greatly appreciated!


message 2: by Michael (new)

Michael Economy (michaeleconomy) Let me ask our andriod guy what he's using.


message 3: by Ettore (last edited Dec 22, 2011 10:32AM) (new)

Ettore Pasquini Hey Grunthos,

we are using patched versions (1.2.1.2) of the oauth-signpost-core and oauth-signpost-commonshttp4 libraries, available from here:

http://code.google.com/p/oauth-signpo...
http://code.google.com/p/oauth-signpo...

The version of the org.apache.httpcomponents library (core and client) we use is 4.0.1.

You're probably already using these if the square brackets are being encoded correctly, but I thought to mention it anyway, because the official 1.2.1.1 release of OAuth-Signpost didn't work for us.

Hopefully this helps.


message 4: by Grunthos (new)

Grunthos | 60 comments Hi,

Thanks for the quick reply...if you don't mind, I still have a couple of questions.

1) Do you set the 'percentEncode' parameter to true? The library I am currently using (Scribe) did the encoding, and I tried a patched version that did not encode the keys, but I got the same errors.

2) From what I can tell, you do not use oauth_verifier in the callback...is that right? If so, when building the access key, do you just use a blank verifier?

Thanks again!


message 5: by Grunthos (new)

Grunthos | 60 comments Hi Again,

I'm now using signpost....and getting 'not found' again. Here is a snippet of the code (after getting access token):

HttpPost post = new HttpPost("http://www.goodreads.com/user_shelves...
HttpParams params = new BasicHttpParams() ;
params.setParameter("user_shelf[name]", "Test");
post.setParams(params);
consumer.sign(post);
HttpClient httpClient = new DefaultHttpClient();
HttpResponse response = httpClient.execute(post);

...and the response is 'Not Found'. I have also tried without the %5D/D in the url.

Any help would be greatly appreciated!


message 6: by Grunthos (new)

Grunthos | 60 comments The Apache components I am using are 4.1.something...I could try downgrading, but if you could look at the above code...to make sure I am not doing something obviously stupid, that would be great!


message 7: by Grunthos (new)

Grunthos | 60 comments Hmmm....another update; I just noticed I should be using 'put' not 'post', so changed the component...and without the %5B/D in the URL I get a 200/OK response, but the shelf name is not changed. With the %5B/D in the URL, I get 404/Not Found...so still a sad panda.


message 8: by Grunthos (new)

Grunthos | 60 comments And downgrading apache libs to 4.0.1 has the same result...must be something really stupid I am doing in this code:

HttpPut post = new HttpPut("http://www.goodreads.com/user_shelves...
HttpParams params = new BasicHttpParams() ;
params.setParameter("user_shelf[name]", "Test");
post.setParams(params);
consumer.sign(post);
HttpClient httpClient = new DefaultHttpClient();
HttpResponse response = httpClient.execute(post);


message 9: by Grunthos (new)

Grunthos | 60 comments Looks like it finally works by setting the parameters based.on.code.in YAGRAC. Yay!

Thanks for the help, and thanks to Adam from YAGRAC for making it open source.


back to top