FQL Your statement is not indexable, but fine in console

烂漫一生 提交于 2019-12-11 10:44:05

问题


I'm using this query for FQL:

SELECT pid, object_id, caption, like_info, comment_info, src, src_small, src_big, images FROM photo WHERE album_object_id="10151088306597851" ORDER BY like_info DESC 

which works fine in the console, check: https://developers.facebook.com/tools/explorer?method=GET&path=fql%3Fq%3DSELECT%20pid%2C%20object_id%2C%20caption%2C%20like_info%2C%20comment_info%2C%20src%2C%20src_small%2C%20src_big%2C%20images%20FROM%20photo%20WHERE%20album_object_id%3D%2210151088306597851%22%20ORDER%20BY%20like_info%20DESC

But when I use the Javascript SDK with FB.api() method it fails with error 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" But according to the docs of table "photo" "album_object_id" IS indexable..

This is my Javascript code:

    if (album_object_id) {
        var query = 'SELECT pid, object_id, caption, like_info, comment_info, src, src_small, src_big, images FROM photo WHERE album_object_id="' + album_object_id + '" ORDER BY like_info DESC';
        //console.log(query);return;
        FB.api('/fql?q=' + encodeURI(query), callback);
    }

When I log query and copy/paste it into the graph API console, it works fine..

Any clues??

cheers Sjoerd


回答1:


I think there is a query encoding issue introduced by encodeURI on this syntax. The following code works perfectly and returns 82 items:

var query = 'SELECT pid, object_id, caption, like_info, comment_info, src, src_small, src_big, images FROM photo WHERE album_object_id="10151088306597851" ORDER BY like_info DESC';

FB.api('/fql', {q: query}, function(r) {
        console.log(r)
    });
}


来源:https://stackoverflow.com/questions/13028526/fql-your-statement-is-not-indexable-but-fine-in-console

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!