-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathcsharp-calls.cs
32 lines (28 loc) · 1.2 KB
/
csharp-calls.cs
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
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
public class ElkSendSMS
{
static public void Main ()
{
Console.WriteLine ("Trying to send");
var username = "<API Username>";
var password = "<API Password>";
var postData = new List<KeyValuePair<string, string>>()
{
new KeyValuePair<string, string>("from", "+4676865201"),
new KeyValuePair<string, string>("to", "+46723175800"),
new KeyValuePair<string, string>("voice_start", '{"connect":"+461890510"}')
};
string creds = string.Format("{0}:{1}", username, password);
byte[] bytes = Encoding.ASCII.GetBytes(creds);
var header = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(bytes));
var content = new FormUrlEncodedContent(postData);
HttpClient Client = new HttpClient();
Client.DefaultRequestHeaders.Authorization = header;
var responseMessage = Client.Post("https://api.46elks.com/a1/Calls", content);
var response = esponseMessage.Content.ReadAsString();
Console.WriteLine (response);
}
}