-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathsend-sms
42 lines (38 loc) · 1.33 KB
/
send-sms
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace elktest {
class Program {
public static string user = "<API-Username>";
public static string pwd = "<API-Password>";
private static HttpClient client;
static void Main(string[] args)
{
Task.Run(async() = > {
using(client = new HttpClient()) {
client.BaseAddress = new Uri("https://api.46elks.com");
client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue(
"Basic",
Convert.ToBase64String(
System.Text.ASCIIEncoding.ASCII.GetBytes(
string.Format("{0}:{1}", user, pwd))));
var content = new FormUrlEncodedContent(new[] {
new KeyValuePair < string, string > ("from", "SharpElk"),
new KeyValuePair < string, string > (
"to", "+46735417172"),
new KeyValuePair < string, string > (
"message",
"Test 😊 message to you!"),
});
HttpResponseMessage response = await client
.PostAsync("/a1/SMS", content);
response.EnsureSuccessStatusCode();
var result = await response.Content.ReadAsStringAsync();
}
}).Wait();
}
}
}