Exemplo n.º 1
0
        private long Create(facebookevent event_info, bool isAsync, CreateEventCallback callback, Object state)
        {
            var parameterList = new Dictionary <string, string> {
                { "method", "facebook.events.create" }
            };
            var dict = new Dictionary <string, string>
            {
                { "name", event_info.name },
                { "category", event_info.event_type },
                { "subcategory", event_info.event_subtype },
                { "host", event_info.host },
                { "location", event_info.location },
                { "city", event_info.venue.city },
                { "end_time", event_info.end_time.ToString() },
                { "start_time", event_info.start_time.ToString() }
            };

            if (event_info.venue.street != null)
            {
                dict.Add("street", event_info.venue.street);
            }
            if (event_info.description != null)
            {
                dict.Add("description", event_info.description);
            }
            if (event_info.privacy != null)
            {
                dict.Add("privacy_type", event_info.privacy);
            }
            if (event_info.tagline != null)
            {
                dict.Add("tagline", event_info.tagline);
            }

            Utilities.AddJSONAssociativeArray(parameterList, "event_info", dict);

            if (isAsync)
            {
                SendRequestAsync <events_create_response, long>(parameterList, !string.IsNullOrEmpty(Session.SessionKey), new FacebookCallCompleted <long>(callback), state);
                return(0);
            }

            var response = SendRequest <events_create_response>(parameterList, !string.IsNullOrEmpty(Session.SessionKey));

            return(response == null ? 0 : response.TypedValue);
        }
        private long Create(facebookevent event_info, bool isAsync, CreateEventCallback callback, Object state)
        {
            var parameterList = new Dictionary<string, string> { { "method", "facebook.events.create" } };
            var dict = new Dictionary<string, string>
            {
                {"name", event_info.name},
                {"category", event_info.event_type},
                {"subcategory", event_info.event_subtype},
                {"host", event_info.host},
                {"location", event_info.location},
                {"city", event_info.venue.city},
                {"end_time", event_info.end_time.ToString()},
                {"start_time", event_info.start_time.ToString()}
            };
            if (event_info.venue.street != null)
            {
                dict.Add("street", event_info.venue.street);
            }
            if (event_info.description != null)
            {
                dict.Add("description", event_info.description);
            }
            if (event_info.privacy != null)
            {
                dict.Add("privacy_type", event_info.privacy);
            }
            if (event_info.tagline != null)
            {
                dict.Add("tagline", event_info.tagline);
            }

            Utilities.AddJSONAssociativeArray(parameterList, "event_info", dict);

            if (isAsync)
            {
                SendRequestAsync<events_create_response, long>(parameterList, !string.IsNullOrEmpty(Session.SessionKey), new FacebookCallCompleted<long>(callback), state);
                return 0;
            }

            var response = SendRequest<events_create_response>(parameterList, !string.IsNullOrEmpty(Session.SessionKey));
            return response == null ? 0 : response.TypedValue;
        }
Exemplo n.º 3
0
 /// <summary>
 /// Creates an event on behalf of the user if the application has an active session; otherwise it creates an event on behalf of the application.
 /// </summary>
 /// <example>
 /// <code>
 /// private static void RunDemoAsync()
 /// {
 ///     Api api = new Api(new DesktopSession(Constants.ApplicationKey, Constants.ApplicationSecret, Constants.ApplicationSecret, Constants.SessionKey));
 ///     facebookevent eventInfo = new facebookevent
 ///     {
 ///         description = "event description",
 ///         end_date = DateTime.Now.AddDays(7),
 ///         event_subtype = "1",
 ///         event_type = "1",
 ///         location = "location",
 ///         venue = new location { city = "chicago" },
 ///         start_date = DateTime.Now.AddDays(1),
 ///         host = "Facebook Samples",
 ///         name = "test event"
 ///     };
 ///     api.Events.CreateAsync(eventInfo, AsyncDemoCompleted, null);
 /// }
 ///
 /// private static void AsyncDemoCompleted(long result, Object state, FacebookException e)
 /// {
 ///     var actual = result;
 /// }
 /// </code>
 /// </example>
 /// <param name="eventInfo">The event information. See the Facebook API Notes for information on what parameters to include in the object.</param>
 /// <param name="callback">The AsyncCallback delegate</param>
 /// <param name="state">An object containing state information for this asynchronous request</param>
 /// <returns>This method returns the identifier of the created event.</returns>
 /// <remarks>
 /// Create an event - You must pass the following parameters in the event_info array:
 /// name
 /// category
 /// subcategory
 /// location
 /// start_time
 /// end_time
 /// The start_time and end_time are the times that were input by the event creator, converted to UTC after assuming that they were in Pacific time (Daylight Savings or Standard, depending on the date of the event), then converted into Unix epoch time.
 ///
 /// Optionally, you can pass the following parameters in the event_info array:
 ///
 /// street
 /// phone
 /// email
 /// host_id
 /// host
 /// desc
 /// privacy_type
 /// tagline
 /// </remarks>
 public void CreateAsync(facebookevent eventInfo, CreateEventCallback callback, Object state)
 {
     Create(eventInfo, true, callback, state);
 }
 /// <summary>
 /// Creates an event on behalf of the user if the application has an active session; otherwise it creates an event on behalf of the application.
 /// </summary>
 /// <example>
 /// <code>
 /// private static void RunDemoAsync()
 /// {
 ///     Api api = new Api(new DesktopSession(Constants.ApplicationKey, Constants.ApplicationSecret, Constants.ApplicationSecret, Constants.SessionKey));
 ///     facebookevent eventInfo = new facebookevent
 ///     {
 ///         description = "event description",
 ///         end_date = DateTime.Now.AddDays(7),
 ///         event_subtype = "1",
 ///         event_type = "1",
 ///         location = "location",
 ///         venue = new location { city = "chicago" },
 ///         start_date = DateTime.Now.AddDays(1),
 ///         host = "Facebook Samples",
 ///         name = "test event"
 ///     };
 ///     api.Events.CreateAsync(eventInfo, AsyncDemoCompleted, null);
 /// }
 ///
 /// private static void AsyncDemoCompleted(long result, Object state, FacebookException e)
 /// {
 ///     var actual = result;
 /// }
 /// </code>
 /// </example>
 /// <param name="eventInfo">The event information. See the Facebook API Notes for information on what parameters to include in the object.</param>
 /// <param name="callback">The AsyncCallback delegate</param>
 /// <param name="state">An object containing state information for this asynchronous request</param>        
 /// <returns>This method returns the identifier of the created event.</returns>
 /// <remarks>
 /// Create an event - You must pass the following parameters in the event_info array: 
 /// name 
 /// category 
 /// subcategory 
 /// location 
 /// start_time 
 /// end_time 
 /// The start_time and end_time are the times that were input by the event creator, converted to UTC after assuming that they were in Pacific time (Daylight Savings or Standard, depending on the date of the event), then converted into Unix epoch time. 
 ///
 /// Optionally, you can pass the following parameters in the event_info array: 
 ///    
 /// street 
 /// phone 
 /// email 
 /// host_id 
 /// host 
 /// desc 
 /// privacy_type 
 /// tagline 
 /// </remarks>
 public void CreateAsync(facebookevent eventInfo, CreateEventCallback callback, Object state)
 {
     Create(eventInfo, true, callback, state);
 }