0

This is my java code, and the URL String which I am passing as a parameter. If I copy paste the URL on the browser it works.

String strURL="SELECT post_id, actor_id, permalink, message, impressions, type, likes, comment_info, share_count, created_time , updated_time FROM stream WHERE source_id='<srcid>'";

    OAuthRequest authRequest = new OAuthRequest(Verb.GET, "https://graph.facebook.com/fql");
    authRequest.addBodyParameter("q", strURL);
    service.signRequest(accessToken, authRequest);
    Response authResponse = authRequest.send();
    System.out.println(authResponse.getBody());

Error Message - 20:12:58,986 INFO [stdout] (http-localhost-127.0.0.1-8080-2) {"error":{"message":"(#601) Parser error: unexpected end of query.","type":"OAuthException","code":601}}

Amit Pandey
  • 1,436
  • 2
  • 24
  • 34
  • Some questions: 1) You have an extra space at `created_time , ` 2) Have you looked at what is actually being sent to Facebook? That error suggests your query is truncated at `type`. – cpilko Apr 15 '13 at 15:22
  • I have removed the extra spaces. I have also removed the column type...but it still give the same exception. I believe it is exception of type OAuthException, however it says unexpected end of query. – Amit Pandey Apr 15 '13 at 15:28
  • I haven't ever seen Facebook give a parse error instead of an OAuth error. Your syntax looks correct. There must be some other issue. – cpilko Apr 15 '13 at 15:36

1 Answers1

0

Thanks cpilko. Actually it was my misinterpretation of scribe OAuth. Instead of authRequest.addBodyParameter, I should be using authRequest.addQuerystringParameter.

The code works now, and I am able to receive the response.

Amit Pandey
  • 1,436
  • 2
  • 24
  • 34