4

我使用 facebook-php-sdk 为页面创建事件。

现在如此处所述可以将图片上传到事件。

问题在于,这是个人资料图片。但一年多以来,Facebook 为活动提供了新的大型封面照片。我想将图片上传到那里,而不是作为个人资料图片。那可能吗?我在Facebook Developer Graph Api 事件页面上没有找到任何帮助,因为这里只描述了上传个人资料图片的方法(HTTP POST TO /EVENT_ID/picture)。

简而言之:是否可以通过 Graph API 上传活动的封面照片?

更新:我尝试将图片上传到页面相册并检索图片ID。然后我尝试选择这张照片作为活动的封面照片。

$cover = array(
    'cover' => $uploaded_photo_id,
);          
$fb->api('/' . $this->FacebookEventID, 'POST', $cover);

可悲的是,这不起作用,因为它直接在页面上。

我开始想,这在目前是不可能的。

另外,如果您通过网站设置封面照片,您可以查询https://graph.facebook.com/Event_ID?fields=cover将返回封面的图形api。

更新:

我仍然没有成功。但如果你回答,请记住:我要上传活动封面图!不是个人资料图片

4

3 回答 3

6

All answers above are wrong! There is only one way to create the Cover Image:

Create The Event:

$eventData = array(
    'name' => 'Event Title',
    'start_time' => 'StarttimeInCorrectFormat',
    'description' => 'Event Description'
);
$fbEvent = $fb->api('/PAGE_ID/events/', 'post', $eventData);

Update the Event using the ID from above:

$cover['cover_url']     = 'http://urlToCoverImage.jpg';
$eventUpdate = $facebook->api( "/" . $fbEvent['id'], 'post', $cover );

return true or false.

And thats it. Cover is in.

于 2013-05-31T16:26:33.597 回答
0

是的。您可以使用 Graph API 上传封面照片。创建活动后,您可以使用 cover_url 字段上传封面照片。'cover_url' => 照片的网址。

于 2013-04-03T18:38:42.887 回答
0

我刚刚想出了如何使用 Facebook PHP SDK 来做到这一点:

1-使用在页面上发布 Facebook 事件

$attachment = array(
    'access_token' => $access_token,
    'name' => $title,
    'start_time' => $start_time,
    'description' => $description
);
$res = $fb->api('/PAGE_ID/events/', 'post', $attachment);

2- Retrieve the EVENT_ID from the result of the post

$fb_event_id = $res['id'];

3- Update the event by calling /EVENT_ID with the cover parameter

$attachment['cover'] = '@/path/to/image.jpg';                                   
$fb->api('/'.$fb_event_id, 'post', $attachment);

That's it !!

于 2013-05-20T15:37:32.487 回答