Skip to content

Instantly share code, notes, and snippets.

@jferguson
Created March 29, 2012 23:09
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 jferguson/2244773 to your computer and use it in GitHub Desktop.
Save jferguson/2244773 to your computer and use it in GitHub Desktop.
.Net Phaxio - Send Fax w /HttpClient
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