Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

facebook

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

Thanks.

like image 227
user186131 Avatar asked Jan 21 '10 12:01

user186131


People also ask

What type of API is Facebook?

The Graph API is the primary way to get data into and out of the Facebook platform. It's an HTTP-based API that apps can use to programmatically query data, post new stories, manage ads, upload photos, and perform a wide variety of other tasks.

How do I get my Facebook API User ID?

The simplest way to get a copy of the User Profile object is to access the /me endpoint: FB. api('/me', function(response) { }); This will this will return the users name and an ID by default.

Is C# used in Facebook?

We're excited to announce the Facebook C# SDK alpha release. This is our first official C# SDK, built to meet the needs of the significant community of Facebook developers using C#. The SDK has a number of features.


2 Answers

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.

like image 194
Balaji Birajdar Avatar answered Nov 15 '22 08:11

Balaji Birajdar


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

like image 41
falcon Avatar answered Nov 15 '22 07:11

falcon