[英]Facebook albums cover photo using latest facebook SDK?
We can fetch facebook photo albums details using garph API {user-id}/albums
我们可以使用garph API {user-id}/albums
获取Facebook相册的详细信息
/*make API call*/
new GraphRequest(
AccessToken.getCurrentAccessToken(), //your fb AccessToken
"/" + AccessToken.getCurrentAccessToken().getUserId() + "/albums",//user id of login user
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(final GraphResponse response) {
}
}).executeAsync();
Now i need to get cover photo of those albums and i know using garph API {albums-id}/picture
we can do that.like below 现在,我需要获取那些专辑的封面照片,并且我知道使用garph API {albums-id}/picture
我们可以做到。如下所示
Bundle params = new Bundle();
params.putString("type", "small"); //You use this to get a pre-specified size of picture.
params.putBoolean("redirect", false);
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/" + id + "/picture",
params,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
}
}).executeAsync();
But we need to make a different API call for it.is there any way to get albums cover photo along with albums details ? 但是我们需要对其进行不同的API调用。是否有任何方法可以获取相册封面照片以及相册详细信息?
and also I'm getting less quality cover photos. 而且我得到的封面照片质量也不太高。
I have tried with all types from here 我从这里尝试了所有类型
type : enum{thumbnail,small,album}
You can't get a larger image than album
. 您无法获得比album
更大的图像。 That's the size you're seeing on the FB album overview page. 这就是您在FB专辑概述页面上看到的大小。
To get the data with one call, you have to use the Field API like this: 要一次调用即可获取数据,您必须像这样使用Field API :
GET /mashable/albums?fields=id,name,picture.type(album)
With the Android SDK, the code should be 使用Android SDK时,代码应为
GraphRequest request = new GraphRequest(
AccessToken.getCurrentAccessToken(), //your fb AccessToken
"/" + AccessToken.getCurrentAccessToken().getUserId() + "/albums",//user id of login user
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(final GraphResponse response) {
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,picture.type(album)");
request.setParameters(parameters);
request.executeAsync();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.