Created
May 15, 2018 15:27
-
-
Save carloshenriqueribeiro/0b879e1655e7eedd605e264d50a45742 to your computer and use it in GitHub Desktop.
Call SMSAsync
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 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