开发者

how to create a facebook event by using facebook api in asp.net

开发者 https://www.devze.com 2022-12-17 11:34 出处:网络
How to开发者_StackOverflow社区 create a facebook event by using facebook api in asp.net. Thanks.public string CreateEvent(string accessToken)

How to开发者_StackOverflow社区 create a facebook event by using facebook api in asp.net.

Thanks.


public string CreateEvent(string accessToken)
    {
        FacebookClient facebookClient = new FacebookClient(accessToken);
        Dictionary<string, object> createEventParameters = new Dictionary<string, object>();
        createEventParameters.Add("name", "My birthday party )");
        createEventParameters.Add("start_time", DateTime.Now.AddDays(2).ToUniversalTime().ToString());
        createEventParameters.Add("end_time", DateTime.Now.AddDays(2).AddHours(4).ToUniversalTime().ToString());
        createEventParameters.Add("owner", "Balaji Birajdar");
        createEventParameters.Add("description", " ( a long description can be used here..)");

        //Add the "venue" details
        JsonObject venueParameters = new JsonObject();
        venueParameters.Add("street", "dggdfgg");
        venueParameters.Add("city", "gdfgf");
        venueParameters.Add("state", "gfgdfgfg");
        venueParameters.Add("zip", "gfdgdfg");
        venueParameters.Add("country", "gfdgfg");
        venueParameters.Add("latitude", "100.0");
        venueParameters.Add("longitude", "100.0");
        createEventParameters.Add("venue", venueParameters);

        createEventParameters.Add("privacy", "OPEN");
        createEventParameters.Add("location", "fhdhdfghgh");

        //Add the event logo image
        FacebookMediaObject logo = new FacebookMediaObject()
        {
            ContentType = "image/jpeg",
            FileName = @"C:\logo.jpg"
        }; 
        logo.SetValue(File.ReadAllBytes(logo.FileName)); 
        createEventParameters["@file.jpg"] = logo;

        JsonObject resul = facebookClient.Post("/me/events", createEventParameters) as JsonObject;
        return resul["id"].ToString();
    }

I am using facebook graph apis with FacebookSdk from codeplex.

I am not able to post the venue with this code due to the open bug in facebook API. Other things work fine. I suggest you implement this venue parameters as well so that the functionality will work as soon as facebook resolves this issue.

Mark this as answer if it works for you.It will also help other people to save time on searching.


You might try this http://developers.facebook.com/docs/api

0

精彩评论

暂无评论...
验证码 换一张
取 消