-
-
Save shahriarhossain/a1d511438911c198e70b 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
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