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?
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.
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.
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.
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.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With