google-code-export / orkut-os-client

Automatically exported from code.google.com/p/orkut-os-client
Apache License 2.0
1 stars 1 forks source link

Empty JSON response #21

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
When i ran the project, after specifying my Consumer key and Secret, the 
Request was made normally, however, the response had problems. The program 
ended with an exception as follows, (by the way I did do the authentication, 
i.e, logged in to my Orkut account to grant access)

Request:[{"params":{"groupId":"@self","userId":"@me"},"id":"0-p.g","method":"peo
ple.get"},{"params":{"groupId":"@friends","userId":"@me","count":20,"startIndex"
:0},"id":"1-frnds.g","method":"people.get"}]
Exception in thread "main" java.lang.RuntimeException: Unexpected exception 
while setting response
    at com.google.orkut.client.api.BatchTransaction.setResponse(BatchTransaction.java:169)
    at com.google.orkut.client.sample.Transport.run(Transport.java:104)
    at com.google.orkut.client.sample.SampleApp.run(SampleApp.java:57)
    at com.google.orkut.client.sample.SampleApp.main(SampleApp.java:43)
Caused by: org.json.me.JSONException: A JSONArray text must start with '[' at 
character 0 of 
    at org.json.me.JSONTokener.syntaxError(JSONTokener.java:448)
    at org.json.me.JSONArray.<init>(JSONArray.java:106)
    at org.json.me.JSONArray.<init>(JSONArray.java:145)
    at com.google.orkut.client.api.BatchTransaction.setResponse(BatchTransaction.java:159)
    ... 3 more

Original issue reported on code.google.com by uzairja...@gmail.com on 29 Jul 2010 at 6:54

GoogleCodeExporter commented 9 years ago
I'm having the same problem. Any ideas on how to do a quick fix for this? I 
can't even test the API.

Original comment by pueloce...@gmail.com on 9 Aug 2010 at 8:31

GoogleCodeExporter commented 9 years ago
It's due to firewall

in Transport class where you set OauthClient for DesktopClient... i.e in init() 
function

use client.setOAuthClient(new OAuthClient(new URLConnectionClient()));

instead of client.setOAuthClient(new OAuthClient(new HttpClient4()));

bcoz HttpClient4() doesn't work behind certain firewalls, hence not letting u 
do the request. Hence, the Json gets nothing to parse.

Original comment by uzairja...@gmail.com on 27 Aug 2010 at 6:21

GoogleCodeExporter commented 9 years ago
Hello that's very helpful

Original comment by trinhcon...@gmail.com on 11 Jan 2011 at 8:14