Facebook Graph API - 来自事件的大图像?

标签 facebook facebook-graph-api koala

所以我目前正在尝试从我为我所属的组织创建的 FB 页面中检索事件图像。当调用 graph.facebook.com/{event-id}/picture 时,我得到一张小得离谱的 50x50 图片。但是,文档列出了“类型”arg ( https://developers.facebook.com/docs/graph-api/reference/event/picture/ ) 的一些大小。当我指定一个大字体时,我得到一个 200x200 像素的图像。

有“高度”和“宽度”字段,但如果我指定任何大于 200 像素的值,例如高度:400 和宽度:350,我会返回 200x200 的图片。从以前的 SO 线程来看,这似乎不是问题,所以我很想知道是否还有其他人遇到过这个问题。

注意:我正在使用 Koala gem ( https://github.com/arsduo/koala) 与 API 交互,但直接浏览器调用返回相同的结果。

最佳答案

事实证明,封面图片有一个 API。您可能认为 Event Picture 文档至少会提到它......但事实并非如此。

封面图片 API: https://developers.facebook.com/docs/graph-api/reference/cover-photo/

这对我有用:

String eventCoverImage = "/v2.8/" + eventId;

Bundle params = new Bundle();
params.putBoolean("redirect", false);
params.putString("fields", "cover");
new GraphRequest(
        AccessToken.getCurrentAccessToken(),
        eventCoverImage,
        params,
        HttpMethod.GET,
        new GraphRequest.Callback() {
            public void onCompleted(final GraphResponse response) {

                // thread is necessary for network call
                Thread thread = new Thread(new Runnable() {
                    @Override
                    public void run() {

                        try {
                            String picUrlString = (String) response.getJSONObject().getJSONObject("cover").get("source");
                            URL imgValue = new URL(picUrlString);
                            Bitmap eventBitmap = BitmapFactory.decodeStream(imgValue.openConnection().getInputStream());
                        } catch (Exception ex) {
                            ex.printStackTrace();
                        }
                    }
                });
                thread.start();
            }

        }
).executeAsync();

此外,这有助于尝试/弄清楚 api 的问题 https://developers.facebook.com/tools/explorer

关于Facebook Graph API - 来自事件的大图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36562278/

相关文章:

facebook - 有人可以结束 "LEAVE APP"的痛苦吗!

ruby - 如何通过 put_wall_post 与 Koala 提及 friend

c++ - 使用 Objective-C 和 C++ 实现 X-FACEBOOK-PLATFORM 身份验证失败

java - 权限错误 - 尝试使用 android facebook sdk 结交 friend

Facebook JavaScript SDK : Publish actions with custom Open Graph objects

java - 如何让 Facebook 上的所有 friend 都点赞?

facebook - 通过 UIActivityViewController 将图像共享到 Facebook/Twitter 在 iOS 8 中停止工作

facebook-graph-api - Facebook Graph API 如何对另一个用户的公开帖子发表评论?

css - 使用 Koala 编译 .scss 时出错

ruby-on-rails - 模型中的 Koala 批处理操作