2013-04-01 22 views
4

我可以在Facebook的图形API Explorer中运行,这让用户ID,用户名,最近的状态,以及个人资料图片,如何执行图形的API,Facebook的Android SDK中

/8794851923?fields=id,name,statuses,picture 

如何使用执行,在机器人Facebook-SDK并获得结果?我试过this,但它已被弃用。

感谢,

回答

5

考虑看看Facebook的样品SDK后,我得到这个:

 Bundle params = new Bundle(); 
    params.putString("fields", "id,name,statuses"); 

final String requestId = "154727011315956"; 

Request request = new Request(session, requestId, params, HttpMethod.GET, new Request.Callback() { 
     public void onCompleted(Response response) { 
       GraphObject graphObject = response.getGraphObject(); 
       FacebookRequestError error = response.getError(); 
       if(error!=null){ 
       Log.e("Error", error.getErrorMessage()); 
       } 

      } 
     }); 

    Request.executeAndWait(request); 
+1

,如果我想要做这样的事情: https://graph.facebook.com/me/photos 会是什么捆绑PARAMS样子? –

+0

我们可以从这个 – Prasad

+0

得到生日什么是'Request'类的确切包?我将android facebook sdk包含到了android studio项目中,但它说'无法解析符号请求' –

0

的图形API是进入和离开Facebook的 社交图的数据的主要方式。这是一个低级的基于HTTP的API,您可以使用它来查询数据,发布新故事,上传照片以及应用程序可能需要执行的各种其他 任务。本指南将教你如何在Graph API中完成所有这些事情。

/* make the API call */ 
new GraphRequest(
    AccessToken.getCurrentAccessToken(), 
    "/me", 
    null, 
    HttpMethod.GET, 
    new GraphRequest.Callback() { 
     public void onCompleted(GraphResponse response) { 
      /* handle the result */ 
        System.out.println("Response::" + String.valueOf(response.getJSONObject())); 

     } 
    } 
).executeAsync(); 

这里,

AccessToken.getCurrentAccessToken()>>登录用户的访问令牌

/ME >>开发自己的个人资料信息

在这里也适用id /用户/页面的名称以获得该信息 like:/joshuatreemusicfestival /职位/

空>>路过这里实际得到哪种类型的用户/页的信息像的参数:

Bundle param = new Bundle(); 
     param.putString("fields", "message,created_time,id,full_picture,status_type,source,comments.summary(true),likes.summary(true)"); 

PARAM更换

HttpMethod.GET >>请求方法[GET,POST,DELETE]

最后onCompleted()调用得到&要响应... !!!

For referance