Created
March 29, 2012 23:09
-
-
Save jferguson/2244773 to your computer and use it in GitHub Desktop.
.Net Phaxio - Send Fax w /HttpClient
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
var fax = new Dictionary<string, string> | |
{ | |
{"to", 8885551212}, | |
{"string_data", "<div>This is your fax in html, will fax just like it renders in webkit, cool huh?</div>")}, | |
{"string_data_type", "html"}, | |
{"api_key", apiKey}, | |
{"api_secret", apiSecret}, | |
{"callback_url", "http://yourwebsite.com/fax/receipt"} | |
}; | |
var content = new FormUrlEncodedContent(fax); | |
var client = new HttpClient(); | |
client.PostAsync(uri, content).ContinueWith( | |
(requestTask) => | |
{ | |
var response = requestTask.Result; | |
response.EnsureSuccessStatusCode(); | |
response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); | |
response.Content.ReadAsAsync<JsonObject>().ContinueWith( | |
(readTask) => | |
{ | |
var json = readTask.Result; | |
var notification = new | |
{ | |
success = json.GetValue("success"), | |
faxId = json.GetValue("faxId"), | |
message= json.GetValue("message") | |
}; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment