Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

  $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. I've tried "source" => '@'.$coverPhoto, "cover" => '@'.$coverPhoto, "cover_url" => '@'.$coverPhoto and:

  $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?

like image 218
Dan Avatar asked Jan 13 '14 23:01

Dan


People also ask

Can you attach a file to a Facebook event?

Facebook doesn't allow attachments that aren't in image file format, such as a PDF or Microsoft Word document, to be posted to your event. This doesn't mean you can't add them.

What size should a Facebook event cover photo be?

And the Facebook event cover photo is the first thing they'll see—so make sure you get the size and design right. The latest specs for the main Facebook event photo are: 1200 x 628 pixels – this is the standard size. 1.91 : 1 ratio – if you want to be precise.

Why is Facebook event cover photo blurry?

Before you create an event on Facebook, you need a cover image with the correct dimensions that will appear of highest quality possible. If an image is smaller than these dimensions, its size will be automatically stretched and it will appear blurry.


2 Answers

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. 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.

like image 122
Rahil Arora Avatar answered Oct 26 '22 22:10

Rahil Arora


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. Use this event_id, to make a call:

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

Code:

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

$facebook->api('/{event-id}', 'POST', $param);
like image 26
Sahil Mittal Avatar answered Oct 26 '22 22:10

Sahil Mittal