Facebook C# SDK, Create Event With Picture

不打扰是莪最后的温柔 提交于 2019-12-02 11:19:29

First you need to realise there are 2 types of pictures for a Facebook event. The old style picture and the new Cover Photo.

If you want to do the old style picture you don't give it a url, you need to pass it the data in one of the arguments to the picture argument.

        var arguments = new Dictionary<string, object>();

        var mediaSource = new FacebookMediaObject
        {
            FileName = "image.jpg",
            ContentType = "image/jpeg"
        };

        mediaSource.SetValue(webClient.DownloadData(url));

        arguments.Add("picture", mediaSource);


        Object value = client.Post(String.Format("/{0}/events/", "facebook_pageId_here"), arguments);

if you want to update that picture it is best to do

        var arguments = new Dictionary<string, object>();

        var mediaSource = new FacebookMediaObject
        {
            FileName = "image.jpg",
            ContentType = "image/jpeg"
        };

        mediaSource.SetValue(webClient.DownloadData(url));

        arguments.Add("source", mediaSource);

        Object value = client.Post(String.Format("/{0}/picture/", "event_id_here"), arguments);

Now if you want to do the cover photo, the only thing I have managed to get working so far is by passing in a url to the cover_url parameter.

        arguments.Add("cover_url", "http://domain.com/image.jpg");
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!