简体   繁体   English

使用facebook事件API将封面照片上传到创建时的facebook事件

[英]Uploading a cover photo to a facebook event on creation using the facebook event API

Using the events API I have the following code to post my event with an event photo 使用事件API我有以下代码用事件照片发布我的事件

  $facebook = new Facebook(array(
      "appId"      => "XXX",
      "secret"     => "XXX",
      "cookie"     => false,
      "fileUpload" => true
  ));

  $data = array("name"=>$eventTitle,
                "start_time"=>$startTime,
                "description"=>$description,
                "privacy_type"=>$privacyType,
                 basename($fileName) => '@'.$fileName
  );

  $result = $facebook->api("/me/events","post",$data);

I'm interested in uploading a cover photo and I haven't found a clear way to do so with the PHP sdk. 我有兴趣上传封面照片,我还没有找到一个明确的方法来使用PHP sdk。 I've tried "source" => '@'.$coverPhoto , "cover" => '@'.$coverPhoto , "cover_url" => '@'.$coverPhoto and: 我已经尝试过"source" => '@'.$coverPhoto"cover" => '@'.$coverPhoto"cover_url" => '@'.$coverPhoto和:

  $data = array("name"=>$eventTitle,
                "start_time"=>$startTime,
                "description"=>$description,
                "privacy_type"=>$privacyType,
                 basename($fileName) => '@'.$fileName,
                 "cover" => array(
                    "source" => '@'.$coverPhoto
                 )
  );

But I can't seem to find the right way to push in a cover photo. 但我似乎无法找到合适的方式来推送封面照片。 Any ideas? 有任何想法吗?

Unfortunately, you can't do it as of now. 不幸的是,你现在不能这样做。

There are two event related endpoints in Graph API: /{event-id} and /{user-id}/events and according to the Graph API documentation , none of them provide a support to upload the Event cover picture. Graph API中有两个与事件相关的端点: /{event-id}/{user-id}/events ,根据Graph API文档 ,它们都没有提供上传事件封面图片的支持。 Also, the documentation does not mention anything about support to upload the event photo (which, I assume, you were successfully able to do with your code). 此外,文档没有提及有关支持上传事件照片的任何内容(我认为,您已成功地使用代码)。

However, based on the official Graph API documentation and my knowledge of Graph API, it's currently not possible to do that. 但是,根据官方的Graph API文档和我对Graph API的了解,目前无法做到这一点。

The method described in the official documentation to upload a cover photo of an event don't work as of now. 官方文档中描述的用于上传活动封面照片的方法现在不起作用。 I've reported this as a bug. 我已将此报告为错误。 You can subscribe to this bug to get any updates regarding the same. 您可以订阅此错误以获取有关相同的任何更新。

The only way to do this (as of now)- 唯一的方法(截至目前) -

Firstly, you cant do this upload cover pic while creating an event. 首先,在创建活动时,您无法执行此上传封面照片。 You first have to create an event, as a result you'll get the event_id . 您首先必须创建一个事件,因此您将获得event_id Use this event_id , to make a call: 使用此event_id拨打电话:

\\POST /{event-id} with param: cover_url \\POST /{event-id} with param: cover_url

Code: 码:

$param = array(
    'cover_url' => '{image-link}'
);

$facebook->api('/{event-id}', 'POST', $param);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM