Skip to content

textmagic/textmagic-rest-csharp

Repository files navigation

Textmagic:: Rest C# Wrapper

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.

What is TextMagic?

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.

Installation

Add the library to your project references or install it as NuGet package.

Usage

  1. Register on TextMagic: https://www.textmagic.com/

  2. 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.

  1. 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.

  2. 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.

  1. Have fun... :)
  2. More ready to use examples are included in the solution.

Requirements

.NET 4.0 or higher

RestSharp (= 105.1.0)

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/textmagic/textmagic-rest-csharp.

License

The library is available as open source under the terms of the MIT License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages