private bool SetCookie(long uid, string cookieName, string value, DateTime? expires, string path, bool isAsync, SetCookieCallback callback, Object state) { var parameterList = new Dictionary<string, string> { { "method", "facebook.data.setCookie" } }; Utilities.AddRequiredParameter(parameterList, "uid", uid); Utilities.AddRequiredParameter(parameterList, "name", cookieName); Utilities.AddRequiredParameter(parameterList, "value", value); Utilities.AddOptionalParameter(parameterList, "expires", DateHelper.ConvertDateToDouble(expires)); Utilities.AddOptionalParameter(parameterList, "path", path); if (isAsync) { SendRequestAsync<data_setCookie_response, bool>(parameterList, !string.IsNullOrEmpty(Session.SessionKey), new FacebookCallCompleted<bool>(callback), state); return true; } var response = SendRequest<data_setCookie_response>(parameterList, !string.IsNullOrEmpty(Session.SessionKey)); return response == null ? true : response.TypedValue; }
/// <summary> /// Set Cookies for the specified user. /// </summary> /// <example> /// <code> /// /// </code> /// </example> /// <param name="uid">User id </param> /// <param name="cookieName">Cookie name </param> /// <param name="value">cookie value </param> /// <param name="expires">Time stamp when the cookie should expire. If not specified, the cookie expires after 24 hours. (The time stamp can be longer than 24 hours and currently has no limit)</param> /// <param name="path">Path relative to the application's callback URL, with which the cookie should be associated. (default value is /) </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 true indicating success or false indicating failure.</returns> public bool SetCookieAsync(long uid, string cookieName, string value, DateTime? expires, string path, SetCookieCallback callback, Object state) { return SetCookie(uid, cookieName, value, expires, path, true, callback, state); }