Jose Adrian
Jose Adrian

Reputation: 1247

(#601) Parser error: unexpected end of query - Javascript FB.api

I have some code that was working one month ago... now, when I check it, it doesn't work. I saw what was the problem, the console says: "unexpected end of query"

I have checked this query on Graph API Tools and it works! I use the same permissions as on my "app".

This is the FQL Query:

SELECT uid,name FROM user WHERE uid IN ( SELECT uid2 FROM friend WHERE uid1 = me() ) ORDER BY name

And this is the complete code:

// This code is in an html file
window.fbAsyncInit = function() { 
FB.init({
      appId      : '226472757418610', 
      status     : true,
      cookie     : true,
      oauth      : true,
      xfbml      : true 
    });
}
...
// this code is in a javascript file and the user is correctly logged in
FB.api('/fql?q=SELECT uid,name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) ORDER BY name', function(amigos) { 
     console.log(amigos)
     // it prints the message above
});

I can't see any error! Could you suggest what could be wrong with my code?

Upvotes: 0

Views: 3134

Answers (1)

Jose Adrian
Jose Adrian

Reputation: 1247

If any have problem with this "unexpected end of query", you could try changing your code for this one:

FB.api('/fql', { q:{"query1":"yourQuery"} }, function(response) {
    // the response is different: 
    var x = response.data[0].fql_result_set;
});

Although is not the best solution.

Update: It's not necessary q to be an object.. It could be only your query and the result could be get it by response.data

Upvotes: 2

Related Questions