Skip to content

Instantly share code, notes, and snippets.

@shahriarhossain
Last active December 7, 2015 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shahriarhossain/a1d511438911c198e70b to your computer and use it in GitHub Desktop.
Save shahriarhossain/a1d511438911c198e70b to your computer and use it in GitHub Desktop.
public class MailChimpReportsOverview
{
/// <summary>
/// Get MailChimp Campaign Reports
/// </summary>
public async Task<ReportOverview> OverviewAsync()
{
string method= "reports";
string server ="us12";
string endpoint = String.Format("https://{0}.api.mailchimp.com/3.0/{1}", server, method);
string content;
using (var client = new HttpClient())
{
try
{
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Basic", Authenticate.FeatchApiKey());
content = await client.GetStringAsync(endpoint).ConfigureAwait(false);
}
catch (Exception ex)
{
using (StreamWriter file = new StreamWriter("c:\\log.txt",true)
{
file.WriteLine(ex.ToString());
}
}
}
return JsonConvert.DeserializeObject<ReportOverview>(content);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment