Skip to content

Instantly share code, notes, and snippets.

@ryanbriones
Created February 16, 2010 16:00
Show Gist options
  • Select an option

  • Save ryanbriones/305615 to your computer and use it in GitHub Desktop.

Select an option

Save ryanbriones/305615 to your computer and use it in GitHub Desktop.
using System.Net;
using System.IO;
using System.Collections;
using System.Collections.Specialized;
using System;
using System.Web;
using System.Security.Cryptography.X509Certificates;
public class Program : ICertificatePolicy {
public bool CheckValidationResult (ServicePoint sp, X509Certificate certificate, WebRequest request, int error) {
return true;
}
public static void Main(string[] args) {
ServicePointManager.CertificatePolicy = new Program ();
using(WebClient client = new WebClient()) {
NameValueCollection postParams = new NameValueCollection();
postParams["username"] = "myemail@test.com";
postParams["api_key"] = "**********";
postParams["other_value"] = "asdasd";
client.UploadData("https://madmimi.com/mailers", "POST",
System.Text.Encoding.UTF8.GetBytes(Program.ConvertNVCToQueryString(postParams)));
}
}
public static String ConvertNVCToQueryString(NameValueCollection paramsNVC) {
string[] pairs = new string[paramsNVC.Keys.Count];
for(int i = 0; i < paramsNVC.Keys.Count; i++) {
string key = paramsNVC.Keys.Get(i);
string value = paramsNVC[key];
pairs[i] = String.Concat(key, "=", HttpUtility.UrlEncode(value));
}
return String.Join("&", pairs);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment