Skip to content

Instantly share code, notes, and snippets.

@carloshenriqueribeiro
Created May 15, 2018 15:27
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 carloshenriqueribeiro/0b879e1655e7eedd605e264d50a45742 to your computer and use it in GitHub Desktop.
Save carloshenriqueribeiro/0b879e1655e7eedd605e264d50a45742 to your computer and use it in GitHub Desktop.
Call SMSAsync
public async void SMSAsync(String mobileNumber)
{
Guid gui = Guid.NewGuid();
using (var httpClient = new HttpClient())
{
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("authorization", "Basic XPTO");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json");
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json");
using (var content = new StringContent("{ " +
"\"sendSmsRequest\": { " +
"\"from\": \"WeBlank\", " +
"\"to\": \"55" + mobileNumber + "\", " +
"\"schedule\": \"2014-08-22T14:55:00\", " +
"\"msg\": \"Aqui vai a mensagem de SMS.\", " +
"\"callbackOption\": \"NONE\", " +
"\"id\": " +
"\"" + gui.ToString() + "\", " +
"\"aggregateId\": \"1111\", " +
"\"flashSms\": false }}", System.Text.Encoding.UTF8,
"application/json"))
{
using (var response = await httpClient.PostAsync("https://api-rest.zenvia360.com.br/services/send-sms", content))
{
string responseData = await response.Content.ReadAsStringAsync();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment