Skip to content

Instantly share code, notes, and snippets.

@adatta02
Created June 8, 2012 14:46
Show Gist options
  • Save adatta02/2895991 to your computer and use it in GitHub Desktop.
Save adatta02/2895991 to your computer and use it in GitHub Desktop.
tru.ly C# example
/*
Copyright (C) 2012 Robert Cayouette <[email protected]>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
const string api_key = "&lt;put your key here&gt;";
/* this is the bad record */
const string user_email = "[email protected]";
const string user_first_name = "Dave";
const string user_last_name = "Smith";
const string user_zip_code = "02139";
const string user_street_address = "222 3rd st.";
const string user_birthday_month = "1";
const string user_birthday_day = "1";
const string user_birthday_year = "1980";
const string user_last_four_social = "1234";
const string user_opted_in = "true";
var encoding = new ASCIIEncoding();
var postData = "?api[key]=" + api_key;
postData += "&user[email]=" + user_email;
postData += "&user[first_name]=" + user_first_name;
postData += "&user[last_name]=" + user_last_name;
postData += "&user[zip_code]=" + user_zip_code;
postData += "&user[street_address]=" + user_street_address;
postData += "&user[birthday_month]=" + user_birthday_month;
postData += "&user[birthday_day]=" + user_birthday_day;
postData += "&user[birthday_year]=" + user_birthday_year;
postData += "&user[last_four_social]=" + user_last_four_social;
postData += "&user[opted_in]=" + user_opted_in;
HttpWebRequest request = null;
WebResponse webresponse = null;
StreamReader rdr = null;
string outData = string.Empty;
try
{
var finalRequest = string.Format("https://tru.ly/api-verify-user" + postData);
request = WebRequest.Create(finalRequest) as HttpWebRequest;
if (request != null)
{
request.Method = "POST";
request.KeepAlive = false;
request.Timeout = 5000;
webresponse = request.GetResponse();
{
rdr = new StreamReader(webresponse.GetResponseStream());
outData = rdr.ReadToEnd();
}
}
}
catch (Exception ex)
{
throw ex;
}
/* Write the value of the variable: outData */
System.Diagnostics.Debugger.Break();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment