-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathsend-sms-with-shortlinks.cs
32 lines (28 loc) · 1.19 KB
/
send-sms-with-shortlinks.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.Text;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
string apiUrl = "https://api.46elks.com/a1/sms";
string apiUsername = "<API_USERNAME>";
string apiPassword = "<API_PASSWORD>";
// auth
var client = new HttpClient();
var authHeader = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{apiUsername}:{apiPassword}"));
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", authHeader);
// data
var content = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("from", "CsElk"),
new KeyValuePair<string, string>("to", "+46720000000"),
new KeyValuePair<string, string>("message", "This will be a shortlink: https://yourdomain.com/events/cool_workshop/signup"),
new KeyValuePair<string, string>("shortlinks", "default")
});
var response = await client.PostAsync(apiUrl, content);
string responseString = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseString);
}
}