简体   繁体   English

从Facebook获取专辑

[英]Fetch albums from Facebook

I have tried to fetch all album IDs from facebook using the following code. 我试图使用以下代码从Facebook获取所有相册ID。 But only first 25 albums were returned. 但只有前25张专辑被退回。 Did I miss something? 我错过了什么?

response = facebook.request("me/albums");
json = Util.parseJson(response);
albums = json.getJSONArray("data");
for (int i =0; i < albums.length(); i++) {
    JSONObject album = albums.getJSONObject(i);
    String album_name = album.getString("name");
    String album_id = album.getString("id");
}

But only first 25 albums were returned. 但只有前25张专辑被退回。 Did I miss something? 我错过了什么?

Yes – that 25 is the default limit parameter value for requests like this. 是 - 25是这样的请求的默认limit参数值。

Either use the paging links to retrieve the next 25 and so on, or set a higher limit yourself. 使用分页链接检索下一个25等等,或者自己设置更高的限制。

https://developers.facebook.com/docs/reference/api/pagination/ https://developers.facebook.com/docs/reference/api/pagination/

I use following ways to get the rest of album list. 我使用以下方法来获取其余的专辑列表。

next_page_URL = null; 
next = json.getJSONObject("paging"); 
next_page_URL = next.getString("next"); 
response = facebook.request("me/albums&"+next_page_URL);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM