如何在安卓中从facebook fql查询中获取json响应



我正在使用 fql 查询来获取 json 响应。我是此 fql 执行过程的新手。我可以详细了解如何执行此查询吗?我看到一些侦听器类在获得响应时使用,

从流中选择likes.user_likes,其中post_id ='XXXXXXXXXXXXX_XXXXXXXXX'

我需要任何东西来执行它并获得响应吗?

提前致谢

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 方法中完成。

最新更新