Search code examples
facebookfacebook-php-sdkfacebook-wall

Share facebook event to my wall


I can't seem to get the picture of the event, and it also gives me a fatal error trying to connect to the event image.
Can I share an (already created) event (not create one, just link to it - with a picture and description) and post it to my wall?

He is what I already have:

$facebook->api('/me/feed', 'post', array(
          'message' => 'event test',
          'link' => 'https://www.facebook.com/events/event id/',
          'picture' => 'https://www.facebook.com/events/event id/',//produces an error
          'name' => 'event test',
          'caption' => '',
          'description' => 'event desc',
    ));

Solution

  • This:

    $facebook->api('/me/feed', 'post', array(
       'link' => 'https://www.facebook.com/events/event id/'
    ));
    

    doesn't work? All of the other info should be available for facebook.


    Edit

    I have no idea why simply sharing the event does not work. Even when supplying the info, the image can not be loaded (as you wrote) with a message saying the pics served from the fb CDNs can't be shared.

    I have two possible workarounds for you though:

    1) You can ask for the event info using the api and then publish that, for example with the js sdk:

    FB.api("EVENT_ID", function(response) {
        FB.ui({
            method: "feed",
            link: "http://www.facebook.com/events/EVENT_ID/",
            name: response.name,
            description: response.description
        });
    });
    

    As for the image, since you are doing it on your servers then you can download the image (https://graph.facebook.com/EVENT_ID/picture?type=large), store it on your server and then add it to the post.

    2) According to the Invited connection of the Event object:

    You can invite users to an event by issuing an HTTP POST to /EVENT_ID/invited/USER_ID. You can invite multiple users by issuing an HTTP POST to /EVENT_ID/invited?users=USER_ID1,USER_ID2,USER_ID3. Both of these require the create_event permission and return true if the invite is successful.

    So with that you can invite the friends to the event directly.
    I know it's not the same, but it might be better than nothing, depending on what you need this for.


    I recommend that you open a bug report on the Bugs system.