【发布时间】:2016-04-11 19:59:15
【问题描述】:
我必须在其中获取用户相册和整个图像。到目前为止我做了什么。
第 1 步:获取用户相册详细信息
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,picture.type(album),count");
new GraphRequest(
AccessToken.getCurrentAccessToken(), //your fb AccessToken
"/" + AccessToken.getCurrentAccessToken().getUserId() + "/albums",//user id of login user
parameters,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(final GraphResponse response) {
}
}).executeAsync();
第 2 步:使用相册 ID 获取相册中的图片
Bundle parameters = new Bundle();
parameters.putString("fields", "images");
parameters.putString("limit", count);
/* make the API call */
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/" + albumId + "/photos",
parameters,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
}
}).executeAsync();
你可以看到我指定了parameters.putString("limit", count);
当请求专辑图片时,count 是专辑中可用的图片。一旦计数超出100,响应没有返回所有数据。在这里我开始知道需要分页之类的东西。我该怎么做用于检索相册中所有可用图像的基于偏移量的分页?谁能帮帮我。
【问题讨论】:
-
developers.facebook.com/docs/graph-api/using-graph-api/#paging // 支持分页的端点的每个 API 响应都会在响应中返回前进/后退链接;虽然我不确定您是否可以将该 URL 直接传递给
GraphRequest,或者必须手动传递参数。
标签: android facebook facebook-graph-api pagination