Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在android中从fql查询中获取元素?_Android_Facebook_Facebook Graph Api - Fatal编程技术网

如何在android中从fql查询中获取元素?

如何在android中从fql查询中获取元素?,android,facebook,facebook-graph-api,Android,Facebook,Facebook Graph Api,这是我获取朋友信息的方法: private void getFriendsInfo() { if (currentSession != null && currentSession.isOpened()) { Log.d("fql started", "staarted"); String fqlQuery = "select uid, name, hometown_location, pic_square from user where

这是我获取朋友信息的方法:

private void getFriendsInfo() {
    if (currentSession != null && currentSession.isOpened()) {
        Log.d("fql started", "staarted");
        String fqlQuery = "select uid, name, hometown_location, pic_square from user where uid in (select uid2 from friend where uid1 = me() LIMIT 20)";
        Bundle params = new Bundle();
        params.putString("q", fqlQuery);
        Request request = new Request(currentSession, 
                "/fql", 
                params, 
                HttpMethod.GET, 
                new Request.Callback(){ 

            @Override
            public void onCompleted(Response response) {
                Log.i(TAG, "Got results: " + response.toString());
//here i want to assign String[] uid, name, location, image.
            }
        });
        Request.executeBatchAsync(request);
    } else {
        Log.d("getFriendsInfo", "else activated");
    }         
}
日志:

    Got results: {Response:  responseCode: 200, graphObject:GraphObject{graphObjectClass=GraphObject, 
    state={"data":[

    {"pic_square":"https:\/\/fbcdn-profile-a.akamaihd.net\/hprofile-ak-ash2\/1115780_13962124_1029801849_q.jpg",
    "uid":13962124,
    "hometown_location":null,
    "name":"Jenny Rader"},

    {"pic_square":"https:\/\/fbcdn-profile-a.akamaihd.net\/hprofile-ak-ash1\/276378_33807714_6690800_q.jpg",
    "uid":33807714,
    "hometown_location":null,
    "name":"John J. Rader"}
我已经搜索过了,但我只找到了如何从Facebook获得请求

如何从fqlQuery中获取字符串[]uid、名称、位置、图像中的数据?

Request Request=new Request(session,“/fql”,params,HttpMethod.get,new Request.Callback(){
Request request = new Request(session,"/fql",params,HttpMethod.GET,new Request.Callback(){         
                public void onCompleted(Response response) {

                            GraphObject graphObject = response.getGraphObject();


                            if (graphObject != null)
                            {
                                if (graphObject.getProperty("data") != null)
                                {
                                    try {
                                        String arry = graphObject.getProperty("data").toString();

                                        JSONArray jsonNArray = new JSONArray(arry);

                                        for (int i = 0; i < jsonNArray.length(); i++) {

                                            JSONObject jsonObject = jsonNArray.getJSONObject(i);

                                            String name = jsonObject.getString("name");
                                            String uid = jsonObject.getString("uid");

                                            String pic_square = jsonObject.getString("pic_square");
                                            String hoemtown = jsonObject.getString("hometown_location");

                                            Log.i("Entry", "uid: " + uid + ", name: " + name + ", pic_square: " + pic_square + ", hoemtown: " + hoemtown);
                                        }

                                    } catch (JSONException e) {
                                        // TODO Auto-generated catch block
                                        e.printStackTrace();
                                    }                                       
                                }
                            }

                    }                  
            }); 
            Request.executeBatchAsync(request);                 
        }
    });
未完成公共无效(响应){ GraphObject GraphObject=response.getGraphObject(); if(graphObject!=null) { if(graphObject.getProperty(“数据”)!=null) { 试一试{ 字符串arry=graphObject.getProperty(“数据”).toString(); JSONArray jsonNArray=新JSONArray(arry); for(int i=0;i
将字段名放入jsonObject.getString(“您的字段名”)中