C# wrapper
Send SMS using our .NET class library. We’ve done all the hard work creating the XML, you just need to write a few lines of code.
We’ve packaged Clockwork as a NuGet package, simply run:
Install-Package Clockwork
And here’s how to use it:
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 System;
using System.Net;
using Clockwork;
class DemoSMS
{
static void Main(string[] args)
{
try
{
Clockwork.API api = new API("API_KEY_GOES_HERE");
SMSResult result = api.Send(
new SMS {
To = "447000000000",
Message = "Hello World"
});
if(result.Success)
{
Console.WriteLine("SMS Sent to {0}, Clockwork ID: {1}",
result.SMS.To, result.ID);
}
else
{
Console.WriteLine("SMS to {0} failed, Clockwork Error: {1} {2}",
result.SMS.To, result.ErrorCode, result.ErrorMessage);
}
}
catch (APIException ex)
{
// You’ll get an API exception for errors
// such as wrong username or password
Console.WriteLine("API Exception: " + ex.Message);
}
catch (WebException ex)
{
// Web exceptions mean you couldn’t reach the Clockwork server
Console.WriteLine("Web Exception: " + ex.Message);
}
catch (ArgumentException ex)
{
// Argument exceptions are thrown for missing parameters,
// such as forgetting to set the username
Console.WriteLine("Argument Exception: " + ex.Message);
}
catch (Exception ex)
{
// Something else went wrong, the error message should help
Console.WriteLine("Unknown Exception: " + ex.Message);
}
}
}
Full documentation can be found in the readme file. If you have any questions get in touch.