0

我正在使用 fql 查询来获取 json 响应。我是这个 fql 执行过程的新手。我可以详细了解如何执行这个查询。我已经看到一些 Listener 类在获取响应时正在使用,

SELECT likes.user_likes FROM stream WHERE post_id ='XXXXXXXXXXXXX_XXXXXXXXX'

我是否需要任何东西来执行此操作并获得响应?

提前致谢

4

1 回答 1

0
private void doFQLQuery()
{
    //get the active facebook session
    Session session = Session.getActiveSession();
    //create the fql query
    String fqlQuery = "SELECT likes.user_likes FROM stream WHERE post_id ='XXXXXXXXXXXXX_XXXXXXXXX'";
    //create a bundle for the parameters(your query)    
    Bundle params = new Bundle();
    params.putString("q", fqlQuery);
    //setup the request
    Request request = new Request(session, "/fql", params, HttpMethod.GET, new Request.Callback()
    {         
        public void onCompleted(Response response) 
        {
            //when the request is completed output the results to the log
            Log.i(TAG, "Result: " + response.toString());
        }                  
    }); 
    //execute the request
    Request.executeBatchAsync(request);       
}

您可以使用此代码执行 fql 查询并获取响应。无论您想对结果进行什么处理,都应该在 onCompleted 方法中完成。

于 2013-04-08T11:01:12.873 回答