开发者

Facebook JavaScript SDK for FQL with additional parameter

Facebook deprecated FB.Data.waitOn and FB.Data.query and they recommend we use FB.api instead.

More info: http://developers.facebook.com/blog/post/561/

This sounds easy enough, but I can't seem to pass additional parameters with my FQL request without getting an error from Facebook. For example, I can successfully do this:

FB.api({
    method: 'fql.query',
    query: 'select page_id, name, pic, page_url from page where page_id=' + some_page_id
}, function(response){
    console.log(response);
});

But I'd also like to pass the 'return_ssl_resources=1' additional parameter so that Facebook returns secure resources instead of non-secure ones. However, if I try the following, Facebook returns a "Parser error: unexpected '&' at position 71" error:

FB.api({
    method: 'fql.query',
    query: 'select page_id, name, pic, page_url from page where page_id=' + some_page_id + '&return_ssl_resources=1'
}, function(response){
    console.log(response);
});

Does开发者_如何学编程 anyone know how to pass additional parameters when making FQL requests using the JavaScript SDK?


It turns out that we can pass additional parameters as properties in the first argument to FB.api():

FB.api({
    method: 'fql.query',
    query: 'select page_id, name, pic, page_url from page where page_id=' + some_page_id,
    return_ssl_resources: 1
}, function(response){
    console.log(response);
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜