Welcome to your new textmagic-rest-csharp wrapper! This library provides you with an easy solution to send SMS and receive replies by integrating TextMagic SMS Gateway to your C# / .NET application.
In this directory, you'll find the files you need to be able to create the library binaries and to use them in your application. To experiment with that code, several examples are provided.
TextMagic's application programming interface (API) provides the communication link between your application and TextMagic’s SMS Gateway, allowing you to send and receive text messages and to check the delivery status of text messages you’ve already sent.
https://www.textmagic.com/docs/api/
All these commands can be executed only if you provide a valid username and API password in your requests.
Add the library to your project references or install it as NuGet package.
-
Register on TextMagic: https://www.textmagic.com/
-
Download TextMagic C# Wrapper class library package and reference it in your project.
In Visual Studio, you should go to Project - Add Reference window and locate dll by clicking Browse button.
In SharpDevelop, go to Project - Add Reference - .NET Assembly Browser and choose dll by clicking Browse button.
That's it! Now you can use TextMagic services as described below.
-
Have a look at the TextMagic SMS API Documentation and use the sandbox to experiment with the different API functions and get more technical details.
-
Write Code like:
using System;
using System.Collections.Generic;
using TextmagicRest;
using TextmagicRest.Model;
namespace textmagicsample
{
class Program
{
public static void Main(string[] args)
{
sendMessage();
Console.WriteLine("Check your phone ;-)");
Console.WriteLine("Press any key to continue . . . ");
Console.ReadKey(true);
}
public static void sendMessage()
{
var client = new Client("replace-with-username", "replace-with-user-api-key");
var link = client.SendMessage("Hello from TextMagic API C# Wrapper demo application", "replace-with-phoneNumber-WithInternationalPrefix");
if (link.Success)
{
Console.WriteLine("Message session {0} successfully sent", link.Id);
} else
{
Console.WriteLine("Message was not sent due to following exception: " + link.ClientException.Message);
}
}
}
}
Note: replace "replace-with-username", "replace-with-user-api-key", "replace-with-phoneNumber-WithInternationalPrefix" with the credentials you got during your registration on TextMagic and a valid phone number.
- Have fun... :)
- More ready to use examples are included in the solution.
.NET 4.0 or higher
RestSharp (= 105.1.0)
Bug reports and pull requests are welcome on GitHub at https://github.com/textmagic/textmagic-rest-csharp.
The library is available as open source under the terms of the MIT License.