-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathProgram.cs
52 lines (45 loc) · 1.43 KB
/
Program.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using ScgApi;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace send_sms
{
class Program
{
static async Task SendSms(String senderId, String receipient, String body, SessionOptions opts)
{
using (var session = new Session(opts))
{
var res = MessageRequest.Resource(session);
String id = await res.Create(new MessageRequest()
{
From = "sender_id:" + senderId,
To = new List<String>() { receipient },
Body = body
});
Console.WriteLine("Created message request {0}", id);
}
}
static void Main(string[] args)
{
if (args.Length < 3)
{
Console.WriteLine("Usage: send_sms senderid receipient message [auth-file] [api-url]");
return;
}
var opts = new SessionOptions();
if (args.Length > 3)
opts.AuthFilePath = args[3];
if (args.Length > 4)
opts.BaseUrl = args[4];
try
{
SendSms(args[0], args[1], args[2], opts).Wait();
}
catch (Exception ex)
{
Console.WriteLine("Failed: {0}", ex.ToString());
}
}
}
}