4

I use the facebook-php-sdk to create an event for a page.

Now as described here it is possible to upload a picture to an event.

The problem with that is, that this is the profile picture. But since more than a year now, facebook provides new, large cover photos for events. I want to upload a picture to there, not as a profile picture. Is that possible? I didn't find any help on the Facebook Developer Graph Api Events Page as there only the way to upload a profile picture is described (HTTP POST TO /EVENT_ID/picture).

In short: Is it possible to upload a cover photo for an event via the Graph API?

UPDATE: I tried to upload a picture to the pages photo album and retrieve the picture id. I then tried to select this picture as the cover photo of the event.

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

Sadly, this isn't working as it is directly on pages.

I'm starting to think, that this isn't possible as of now.

Also if you set a cover photo via the website, you can query the graph api with https://graph.facebook.com/Event_ID?fields=cover which will return the cover.

UPDATE:

I still had no success. But if you answer, please keep in mind: I want to upload a cover picture to the event! NOT A PROFILE PICTURE

Community
  • 1
  • 1
Marvin Dickhaus
  • 785
  • 12
  • 27
  • Did you get any success with this? – Sahil Mittal Apr 10 '14 at 14:54
  • @Sahil Mittal See the answer that is marked as accepted below. This approach works. Be aware, that the server you serving your images from has to be an actual server, that is reachable via the public internet. – Marvin Dickhaus Apr 12 '14 at 13:22

3 Answers3

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.

ClubDesign
  • 233
  • 1
  • 4
  • 8
  • I just quote from the last post: Hello, this answer is wrong. As stated before, I want to upload a picture as a cover. Posting an image to ```cover_url``` sets the image as the profile picture of the event, not the cover. – Marvin Dickhaus Jul 20 '13 at 12:41
  • Late answer, but no it does not! The above code sets the image as cover as stated! – ClubDesign Sep 14 '13 at 09:25
  • @ClubDesign I have to revise this. You are correct. This approach works. Thank you very much. – Marvin Dickhaus Sep 19 '13 at 10:31
  • By the way: It seems like Facebook won't accept Links that are SSL encrypted. So https won't work. – Marvin Dickhaus Oct 19 '13 at 17:58
  • it used to work to me, but suddenly it stopped! something have met this problem before? (OAuthException #2) – Almog Baku Dec 20 '13 at 13:13
0

yes. You can upload cover photo using Graph API. Once you have created the event, you can use cover_url field to upload the cover photo. 'cover_url' => url of the photo.

  • 1
    Hello, this answer is wrong. As stated before, I want to upload a picture as a cover. Posting an image to `cover_url` sets the image as the profile picture of the event, not the cover. – Marvin Dickhaus Apr 05 '13 at 12:50
0

I just figured out how to do it using the Facebook PHP SDK:

1- POST the Facebook event on the page using

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

  • Sadly, that's not it: As stated before, I want to upload a picture as a cover. Posting an image to ```cover``` sets the image as the profile picture of the event, not the cover. – Marvin Dickhaus Jul 20 '13 at 12:41