Created
November 1, 2011 20:15
-
-
Save jjoos/1331771 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Specialized; | |
using System.Linq; | |
using System.Net; | |
class Example | |
{ | |
public static void Main (string[] args) | |
{ | |
Subscribe(1905, "[email protected]"); | |
} | |
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