【问题标题】:Facebook albums cover photo using latest facebook SDK?Facebook 相册封面照片使用最新的 Facebook SDK?
【发布时间】:2016-01-07 18:32:24
【问题描述】:

我们可以使用 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();

现在我需要获取这些专辑的封面照片,我知道使用 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();

但我们需要对其进行不同的 API 调用。有没有办法获取专辑封面照片以及专辑详细信息?

而且我得到的封面照片质量也降低了。

我已经尝试过来自here的所有类型

type : enum{thumbnail,small,album}

【问题讨论】:

标签: android facebook facebook-graph-api


【解决方案1】:

您无法获得比album 更大的图像。这就是您在 FB 专辑概览页面上看到的大小。

要一次调用获取数据,您必须像这样使用Field API

GET /mashable/albums?fields=id,name,picture.type(album)

Try it yourself

使用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();

【讨论】:

  • 谢谢托比 :) 解释得很好。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-03-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多