private IList <string> RegisterUsers(ICollection <ConnectAccountMap> accountMaps, bool isAsync, RegisterUsersCallback callback, Object state) { var parameterList = new Dictionary <string, string> { { "method", "facebook.connect.registerUsers" } }; var itemList = new List <string>(); foreach (var accountMap in accountMaps) { var mappingDictionary = new Dictionary <string, string>(); // Compute the email_hash mappingDictionary.Add("email_hash", Utilities.GenerateEmailHash(accountMap.EmailAddress)); // If populated set AccountId if (!string.IsNullOrEmpty(accountMap.AccountId)) { mappingDictionary.Add("account_id", accountMap.AccountId); } // If populated set AccountUrl if (!string.IsNullOrEmpty(accountMap.AccountUrl)) { mappingDictionary.Add("account_url", accountMap.AccountUrl); } itemList.Add(JSONHelper.ConvertToJSONAssociativeArray(mappingDictionary)); } Utilities.AddRequiredParameter(parameterList, "accounts", JSONHelper.ConvertToJSONArray(itemList)); if (isAsync) { SendRequestAsync <connect_registerUsers_response, IList <string> >(parameterList, !string.IsNullOrEmpty(Session.SessionKey), new FacebookCallCompleted <IList <string> >(callback), state); return(null); } var response = SendRequest <connect_registerUsers_response>(parameterList, !string.IsNullOrEmpty(Session.SessionKey)); return(response.connect_registerUsers_response_elt); }
/// <summary> /// Creates an association between an existing user account on your site and that user's Facebook account, provided the user has not connected accounts before (for Facebook Connect). /// </summary> /// <example> /// <code> /// private static void RunDemo() /// { /// ConnectSession connectSession = new ConnectSession(Constants.ApplicationKey, Constants.ApplicationSecret); /// /// /// /// /// NOTE: This is shortened for brevity; would require a postback after completing Facebook Connect authentication. /// /// /// /// if (connectSession.IsConnected()) /// { /// Api _api = new Api(connectSession); /// /// var registerList = new List<ConnectAccountMap>(); /// registerList.Add(new ConnectAccountMap /// { /// EmailAddress = "*****@*****.**", /// AccountId = "10001" /// }); /// _api.Connect.RegisterUsersAsync(registerList, AsyncDemoCompleted, null); /// } /// } /// /// private static void AsyncDemoCompleted(bool result, object state, FacebookException e) /// { /// var actual = result; /// } /// </code> /// </example> /// <param name="accounts">An array of up to 1,000 arrays, or "maps," where each map represent a connected account.</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 a List email hashes that have been successfully registered. If any email hashes are missing, we recommend that you try registering them again later.</returns> public void RegisterUsersAsync(List <ConnectAccountMap> accounts, RegisterUsersCallback callback, Object state) { RegisterUsers(accounts, true, callback, state); }