Facebook Graph API - 事件中的大图像? [英] Facebook Graph API - Large Image from Event?

查看:155
本文介绍了Facebook Graph API - 事件中的大图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在尝试从我为其中一部分组织创建的FB页面中检索事件图像。当打电话给graph.facebook.com/{event-id}/picture我得到一个荒谬的小50x50图像。但是,该文档列出了类型参数的几个大小( https ://developers.facebook.com/docs/graph-api/reference/event/picture/ )。当我指定一个大的类型,我得到一个200x200像素的图像。

So I'm currently trying to retrieve event images from a FB page I created for an organization I'm a part of. When make a call to graph.facebook.com/{event-id}/picture I get an absurdly small 50x50 image. However, the documentation lists a few sizes for the 'type' arg (https://developers.facebook.com/docs/graph-api/reference/event/picture/). When I specify a large type, I get a 200x200px image.

有height和width字段,但是如果我指定大于200px的大小,例如height:400和width:350,我得到一个200x200图片返回。从以前的SO线程看来,这并不是一个问题,所以如果有人遇到这个问题,我有兴趣听。

There are the 'height' and 'width' fields, but if I specify anything larger than 200px, such as height: 400 and width: 350, I get a 200x200 pic returned. From previous SO threads it looks like this didn't used to be a problem, so I'm interested in hearing if anybody else has run into this.

注意:我使用考拉宝石( https://github.com/arsduo/koala )与API,但直接浏览器调用返回相同的结果。

Note: I'm using the Koala gem (https://github.com/arsduo/koala) to interact with the API, but direct browser calls are returning the same result.

推荐答案

原来,封面图片有一个API。你会认为事件图片文件至少会提及它..但不是这样的。

It turns out there's an API for the cover image. You would think the Event Picture docs would at least mention it .. but it's not the case.

封面照片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 img_value = new URL(picUrlString);
                            Bitmap eventBitmap = BitmapFactory.decodeStream(img_value.openConnection().getInputStream());
                        } catch (Exception ex) {
                            ex.printStackTrace();
                        }
                    }
                });
                thread.start();
            }

        }
).executeAsync();

此外,这可以帮助您尝试使用api
< a href =https://developers.facebook.com/tools/explorer =nofollow> https://developers.facebook.com/tools/explorer

Additionally, this can be of help to try/figure things out with the api https://developers.facebook.com/tools/explorer

这篇关于Facebook Graph API - 事件中的大图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆