0

I'm having a hard time creating a facebook event with a picture. I've tried many things found on stackoverflow, but most of them are using the php SDK. Facebook documentation also doen't include an example on how to post a photo to the event.

The code I'm using is:

params = {'name': "some_name",
          'picture':"some_img_url_at_my_server",
          //or 'picture':"@some_img_url_at_my_server",
          //or '@picture':"@some_img_url_at_my_server",
          //or 'source':"some_img_url_at_my_server",
          //or 'source':"@some_img_url_at_my_server",
          //or 'picture':"some_img_path_at_my_server",
          //or 'picture':"@some_img_path_at_my_server",
          //or '@picture':"@some_img_path_at_my_server",
          //or 'source':"some_img_path_at_my_server",
          //or 'source':"@some_img_path_at_my_server",
          'start_time': "some_date"
};


FB.api('/me/events', 'post', params, function (response) {
    if (!response || response.error) {
        log(response.error);
    } else {
        alert('Post ID: ' + response.id);
    }
});

The event gets created but no picture is shown.

I read somewhere that I have to url encode the picture data to the post I'm making but I don't know the way to do that in order to try it.

I fetching the data from a php page so, I could do that in the php page as well, but again, I don't know what I have to do exactly.

Can anyone please help?

Thank you

4

1 回答 1

0

It looks like you have to do this in two steps:

  1. Create the event and get its id.
  2. POST to /EVENT_ID/picture with the picture content in the source parameter.

See here for more details.

于 2013-01-12T04:27:02.440 回答