This library helps with developing against the Spryng SMS Api.
You can use NuGet to easily install the library:
Install-Package SpryngApiHttpDotNet
To use the Spryng HTTP Api you must first create a new instance of the SpryngHttpClient:
var client = SpryngHttpClient.CreateClientWithPassword(username, password);For sending SMS it is also possible to use an api key. Checking of credits does not work.
To send a SMS, you must create a SmsRequest object. You can create one like this:
SmsRequest request = new SmsRequest()
{
Destinations = new string[] { "31612345678", "31698765421" },
Sender = "Spryng",
Body = "This is a Test SMS."
};You can now send the SMS using the client:
try
{
await client.ExecuteSmsRequestAsync(request);
Console.WriteLine("SMS has been send!");
}
catch (SpryngHttpClientException ex)
{
Console.WriteLine("An Exception occured!\n{0}", ex.Message);
}The API also provides an sync implementation which can be used in the same fashion as the asynchronous api:
client.ExecuteSmsRequest(request);There are multiple properties available in the SmsRequest that can be changed.
DestinationsA string array of phone numbers you're sending the sms to.BodyBody of the sms.SenderOriginator address, like your company name.RouteWhether to use Spryng Business, Spryng Economy or a custom route. Defaults tobusiness.ReferenceAn optional reference for delivery reports.AllowLongWhether you want to allow long SMS or not. Defaults toFalse.
It's also possible to request the accounts credit balance using the client. This method is available sycnhronously and asynchronously.
// Synchronous
double remainingCredits = client.GetCreditAmount();
// Asynchronous
double remainingCredits = await client.GetCreditAmountAsync();When using the API Key it is not possible to get your credit amount.