Facebook PHP SDK: Upload Event Cover Photo

前端 未结 3 1184
面向向阳花
面向向阳花 2021-01-06 04:28

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, tha

相关标签:
3条回答
  • 2021-01-06 04:58

    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.

    0 讨论(0)
  • 2021-01-06 05:16

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

    0 讨论(0)
  • 2021-01-06 05:19

    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.

    0 讨论(0)
提交回复
热议问题