为具有报价问题的FQL创建Multiquery

时间:2014-01-30 05:50:07

标签: android facebook facebook-fql

我正在将facebook与我的原生Android应用程序集成。我必须将两个查询一起传递,我知道这可以通过FQL中的multiquery来完成。我正在将我需要转换为多个查询的两个查询。

I have already taken a reference of 
https://developers.facebook.com/docs/android/run-fql-queries/

查询: -

query 1:SELECT id, text, time, fromid, likes,post_id FROM comment WHERE post_id IN('1274243354_10202683234503386')

query 2 : SELECT uid,pic,name FROM user WHERE uid IN (SELECT fromid FROM comment WHERE post_id IN('1274243354_10202683234503386'))

我正在尝试上面的查询作为multiquery并获得结果

multiquery

String postID = "\'" + "1274243354_10202683234503386" + "\'";
        String query1 = "'SELECT post_fbid, fromid, text, time FROM comment WHERE post_id IN (" + postID + ")'";
        String query2 = "'SELECT id, name, url, pic FROM profile WHERE id IN (SELECT fromid FROM #query1)'";

    String fqlQuery = "{" +
            "'query1':" + query1 + "," +
            "'query2':" + query2 +
            "}";

多重查询的结果

{Response:  responseCode: 400, graphObject: null, error: {HttpStatus: 400, errorCode: 601, errorType: OAuthException, errorMessage: (#601) Parser error: unexpected '{' at position 0.}, isFromCache:false}

我犯错误的地方?我无法得到它..

1 个答案:

答案 0 :(得分:3)

'标记了查询的结束:

'SELECT post_fbid, fromid, text, time FROM comment WHERE post_id IN ('

所以,

String postID = "\'" + "1274243354_10202683234503386" + "\'";

应该是:

String postID = "\"" + "1274243354_10202683234503386" + "\"";