Skip to content

Instantly share code, notes, and snippets.

@jjoos
Created November 1, 2011 20:15
Show Gist options
  • Save jjoos/1331771 to your computer and use it in GitHub Desktop.
Save jjoos/1331771 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Specialized;
using System.Linq;
using System.Net;
class Example
{
public static void Main (string[] args)
{
Subscribe(1905, "scott@kickofflabs.com");
}
public static string Subscribe(int landingPageId, string email, NameValueCollection arguments = null)
{
arguments = arguments ?? new NameValueCollection();
arguments.Add("email", email);
var queryString = "?" + String.Join("&", arguments.AllKeys
.Select(item => item + "=" + String.Join(",", arguments.GetValues(item))));
var url = string.Format("http://api.kickofflabs.com/v1/{0}/subscribe", landingPageId);
using (var client = new WebClient())
{
try
{
return client.UploadString(url, queryString);
}
catch (WebException)
{
return "Could not subscribe the email address " + email;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment