public SSOAuthenticationExample() { client = new Client("MASTERKEY", "SECRET"); string sampleUserEmail = "*****@*****.**"; try { Response authResponse = client.AuthenticateMaster(sampleUserEmail); } catch (MemberNotExistException ex) { //Create user on the fly with master account Client masterClient = new Client("MASTERKEY", "SECRET"); masterClient.AuthenticateMaster(); Request request = new Request("member", ApiAction.CREATE); request.AddParameter("screen_name", "Sample User"); request.AddParameter("email", sampleUserEmail); Dictionary<string, object> userCreationResult = masterClient.Execute(request).Deserialize<Dictionary<string, object>>(); //if auto user creation failed, handle it here. //try authenticate again Response authResponse = client.AuthenticateMaster(sampleUserEmail); } Request request2 = new Request("member", ApiAction.INDEX); Dictionary<string, object> result = client.Execute(request2).Deserialize<Dictionary<string, object>>(); ArrayList memberList = (ArrayList)result["member_list"]; }
public AuthenticationExample() { string ClientId = "ClientID"; string ClientSecret = "SECRET"; string Email = "*****@*****.**"; string Password = "******"; //Create the client client = new Client(ClientId, ClientSecret); //client.CustomDomain="auth.brightideasandbox.com"; //Authenticate with user's email and password Response authResponse = client.Authenticate(Email, Password); //Make API request to pull the member list Request request = new Request("member", ApiAction.INDEX); Response response = client.Execute(request); ///////////////////////////////////////// // There are 3 ways to read the response ///////////////////////////////////////// //1.Read data by using JSON.Net JObject json = response.JObject; JArray memberList = (JArray)json["member_list"]; System.Diagnostics.Debug.WriteLine(memberList.Count); //2.Read data by deserializing the json Dictionary<string, object> dictionary = response.Deserialize<Dictionary<string, object>>(); //3.Get the content as string string content = response.Content; }
public MasterAuthenticationExample() { client = new Client("MASTERKEY", "SECRET"); Response authResponse = client.AuthenticateMaster(); Request request = new Request("member", ApiAction.INDEX); Dictionary<string, object> result = client.Execute(request).Deserialize<Dictionary<string, object>>(); ArrayList memberList = (ArrayList)result["member_list"]; Console.WriteLine(memberList.Count); }