【问题标题】:facebook4j retrieve different image size from my facebook postsfacebook4j 从我的 facebook 帖子中检索不同的图像大小
【发布时间】:2014-10-06 16:31:19
【问题描述】:

我正在使用 facebook4j 加载主页帖子facebook.getHome(),我正在获取个人资料图片和帖子图片,如下所示:

facebook4j.User fromUser = facebook.getUser(fbHomePost.getFrom().getId(), 
new Reading().fields("picture"));
if (fromUser.getPicture() != null)                      
  facebookUserPostDto.setProfileImage(fromUser.getPicture().getURL().toURI().toString());
if (fbHomePost.getPicture() != null)
  facebookUserPostDto.setImageLocation(fbHomePost.getPicture().toURI().toString());

一切运行良好,但我从 URL 获取的图像很小且分辨率较低。知道如何使用 facebook4j API 从 facebook 获取“大”图像吗? facebook可以提供不同的图片尺寸API Reference › Graph API › Pictures

谢谢

【问题讨论】:

标签: facebook facebook-java-api


【解决方案1】:

好的,首先您必须将 user_photos 添加到您的范围并确保您使用的是有效的访问令牌不是 Graph API Explorer 令牌

OAuthService service = new ServiceBuilder()
                                      .provider(FacebookApi.class)
                                      .apiKey(apiKey)
                                      .apiSecret(apiSecret)
                                      .callback("xxxx")
                                      .scope("publish_actions,user_photos ")
                                      .build();

然后试试这个:(已测试)

for(Post p : feed){
        System.out.println("********************");
        String type = p.getType();
        System.out.println("type :"+type);
        String idPicVid = p.getObjectId();
        if(type.matches("photo")){
           System.out.println("idPicVid "+idPicVid);
                try{
                    Photo pic = facebook.getPhoto(idPicVid);
                    System.out.println(pic.toString());
                    System.out.println("source "+pic.getSource());
                    System.out.println("picture "+pic.getPicture());
                }catch (Exception e) {
                    e.printStackTrace();
                }
        }
}

【讨论】:

    【解决方案2】:

    好的,我收到了来自 facebook4j 谷歌小组的回复,内容是如何进行此操作 retrieve different image size from my facebook posts

    Sameeh Harfoush

    Brate

    【讨论】:

      猜你喜欢
      • 2015-05-21
      • 2014-08-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-02
      • 2017-08-25
      • 1970-01-01
      相关资源
      最近更新 更多