Click here to Skip to main content
15,915,089 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi...

i want to create an event on facebook.

My code is..

ImpactWorks.FBGraph.Connector.Facebook facebook = new ImpactWorks.FBGraph.Connector.Facebook();
            facebook.AppID = "477037849023683";
            facebook.CallBackURL = "http://localhost:11543/Default.aspx";
            facebook.Secret = "604b3f81c785625e0bf14b565444ce8e";

            //Setting up the permissions
            List<FBPermissions> permissions = new List<FBPermissions>() {
            
               
                FBPermissions.email, //To get user's email address
                FBPermissions.user_about_me, // to read about me
                FBPermissions.user_birthday, // Get DOB
                FBPermissions.user_education_history, //get education
                FBPermissions.user_location, //Location of user
                FBPermissions.user_relationships,//relationship status of user
                FBPermissions.user_work_history,//Workhistory of user
                FBPermissions.user_website,//website entered in fb Profilr
                FBPermissions.create_event,
                FBPermissions.user_events,
                FBPermissions.user_status,
                FBPermissions.read_stream
               
            };

            //Pass the permissions object to facebook instance
            facebook.Permissions = permissions;

            if (String.IsNullOrEmpty(Request.QueryString["code"]))
            {
                String authLink = facebook.GetAuthorizationLink();
                Response.Redirect(authLink);
            }
            else
            {
                //Get the code returned by facebook
                string Code = Request.QueryString["code"];

                //process code for auth token
                facebook.GetAccessToken(Code);

                //Get User info
                FBUser currentUser = facebook.GetLoggedInUserInfo();


                //Create IFBEvent object and add all the details

                IFBEvent eventDetails = new FBEvent();
                eventDetails.EndTime = DateTime.Now.AddDays(2);
                eventDetails.StartTime = DateTime.Now.AddDays(1);
                eventDetails.Location = "Office";
                eventDetails.EventName = "A new secret test event";
                eventDetails.Description = "New";
                eventDetails.Privacy = PrivacyType.OPEN;
               

                var newEventID = facebook.CreateEvent(currentUser.id.GetValueOrDefault(), eventDetails);


eventhing is executing fine..
at the last line i am facing error

var newEventID = facebook.CreateEvent(currentUser.id.GetValueOrDefault(), eventDetails);


please help me. Thanks in advance
Posted

1 solution

Probably you are following this link[^].
You don't mention what error are you getting.But according to that code it seems to me,you don't understand what are you doing inside the code.A list of FBPermissions are used there,but does all of them are valid in your profile? I mean,does your Facebook profile has all values of those permissions? If you get Bad Request error, then you need to know bad request usually occurs when token is invalid or permissions are not there.And a suggestion for you,it would be better if you post your problems on that blog who authored that.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900