2

This FQL multiquery, for example:

https://graph.facebook.com/fql?q={"posts":"SELECT actor_id,message,permalink,created_time,comments.count FROM stream WHERE source_id=me()","actors":"SELECT uid,name,pic_square,profile_url FROM user WHERE uid IN (SELECT actor_id FROM #posts)"}

works perfectly in the Graph API Explorer, but when you put it straight in a browser, you get:

{
        "error": {
        "message": "(#601) Parser error: unexpected '{' at position 0.",
        "type": "OAuthException"
    }
}

What am I missing here? Again something was deprecated by Facebook in their API? I want to do an FQL multiquery using GET (actually using JSONP at the end) - without using the Javascript SDK.

By the way, I am sure it's not an authorization/access_token issue.

Yuval A.
  • 5,849
  • 11
  • 51
  • 63

2 Answers2

8

URLencode the value of parameter q. :, # are special characters in a URL. Example:

https://graph.facebook.com/fql?q=%7B%22posts%22%3A%22SELECT%20actor_id%2Cmessage%2Cpermalink%2Ccreated_time%2Ccomments.count%20FROM%20stream%20WHERE%20source_id%3Dme%28%29%22%2C%22actors%22%3A%22SELECT%20uid%2Cname%2Cpic_square%2Cprofile_url%20FROM%20user%20WHERE%20uid%20IN%20%28SELECT%20actor_id%20FROM%20%23posts%29%22%7D

If your are using PHP use something like this:

$url = 'https://graph.facebook.com/fql?q=' . urlencode($my_fql_query);
Ashwini Dhekane
  • 2,280
  • 14
  • 19
  • BTW, I am getting following error for the same url: { "error": { "message": "(#604) Your statement is not indexable. The WHERE clause must contain an indexable column. Such columns are marked with * in the tables linked from http://developers.facebook.com/docs/reference/fql ", "type": "OAuthException" } } – Ashwini Dhekane Nov 04 '11 at 17:20
  • Yeah, me too, though the real query that I need to use is different than the one I gave as an example. It is weird though that the example-query works in graph API explorer without this error. Anyway, my real query works after properly url-encoding it. I actually did try to use Javascript's URIEncode before, but it wasn't enough. With "real" URL-encoding - it works. Thanks. – Yuval A. Nov 04 '11 at 18:08
0

You need to use: https://graph.facebook.com/fql?queries=...

Don't use 'q', use the param name 'queries'.

Amber Haq Dixon
  • 614
  • 7
  • 9
  • According to [the documentation](https://developers.facebook.com/docs/technical-guides/fql/), the parameter name that you're supposed to use is `q`, not `queries`: "You can issue a `HTTP GET` request to `/fql?q=query` where `query` can be a single fql query or a JSON-encoded dictionary of queries." –  Feb 25 '14 at 22:25