链接页面Feed Graph API android

时间:2015-10-30 08:13:34

标签: android facebook-graph-api

我想在Facebook帖子中获取图片和链接。

enter image description here

我使用的是图谱API,但我无法理解如何操作:

/* make the API call */ new GraphRequest( AccessToken.getCurrentAccessToken(), "/{post-id}", null, HttpMethod.GET, new GraphRequest.Callback() { public void onCompleted(GraphResponse response) { /* handle the result */ } } ).executeAsync();

1 个答案:

答案 0 :(得分:1)

看看

如果你有一个实际的post_id,这将导致这样的调用:

String postId = "21898300328_10154057125545329";

GraphRequest request = GraphRequest.newGraphPathRequest(
        accessToken,
        postId, 
        new GraphRequest.GraphJSONObjectCallback() {
            @Override
            public void onCompleted(
                   JSONObject object,
                   GraphResponse response) {
                // Application code
            }
        });

Bundle parameters = new Bundle();
parameters.putString("fields", "id,message,link,attachments{media{image}}");

request.setParameters(parameters);
request.executeAsync();