SMSNET 0.0.1

dotnet add package SMSNET --version 0.0.1
NuGet\Install-Package SMSNET -Version 0.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SMSNET" Version="0.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SMSNET --version 0.0.1
#r "nuget: SMSNET, 0.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SMSNET as a Cake Addin
#addin nuget:?package=SMSNET&version=0.0.1

// Install SMSNET as a Cake Tool
#tool nuget:?package=SMSNET&version=0.0.1

SMS.NET

An unofficial library for sms-activate.org

Installation

You can install this package via nuget or by compiling the project yourself

Get Started

Get your API key

You can locate your API key by heading here

Create an SMS object

Start by creating an SMS object which will expose all the endpoints that you would need being linked to the API key from the first step

public class Program() {
  public SMS Sms = new SMS("INSERT YOUR API KEY HERE");
}

Note that once you create a new SMS object the library will automatically check your balance which is done to verify that the API key is valid

Profit!!!!

That's it! Once you create the object everything is ready and you can start using the library however you want!

Examples

Get your balance
public class Program() {
  public SMS Sms = new SMS("INSERT YOUR API KEY HERE");
  
  public async Task PrintBalance() {
    var balance = await Sms.Account.GetBalance();
    Console.WriteLine(balance);
  }
}
Get the top countries for Telegram
public class Program() {
  public SMS Sms = new SMS("INSERT YOUR API KEY HERE");
  
  public async Task PrintTopCountries() {
    var topCountriesDictionary = await Sms.Activation.GetTopCountries("tg");
    var telegram = topCountriesDictionary["tg"]; // GetTopCountries always returns a dictionary where the key is the service's name
    int i = 0;
    foreach (var country in telegram.TopCountries) {
      Console.WriteLine($"Place #{i} | Country code: {country.Country} | Price: {country.Price} | Quantity: {country.Count}");
      i++;
    }
  }
}
Get a number for Telegram
public class Program() {
  public SMS Sms = new SMS("INSERT YOUR API KEY HERE");
  
  public async Task PrintMyNumber() {
    var myNumber = await Sms.Activation.GetNumber("tg", (int)Countries.England); 
    // The Countries enum has all sms-activate.org countries, however, you must cast it to int
    Console.WriteLine($"ID: {myNumber.Id} | Created at: {myNumber.CreatedAt.Value} | Number: {myNumber}"); 
    // Casting a Number object to string will always return a properly formatted number (e.g +12029182132)
  }
}
Get a code from a new number (using GetNumber)
public class Program() {
  public SMS Sms = new SMS("INSERT YOUR API KEY HERE");
  
  public async Task PrintMySMS() {
    var myNumber = await Sms.Activation.GetNumber("tg", (int)Countries.England); 
    // The Countries enum has all sms-activate.org countries, however, you must cast it to int
    Console.WriteLine($"ID: {myNumber.Id} | Created at: {myNumber.CreatedAt.Value} | Number: {myNumber}"); 
    // Casting a Number object to string will always return a properly formatted number (e.g +12029182132)
    
    await Task.Delay(5000); // Wait for 5 seconds (you would usually have to wait longer for an SMS)
    
    var myStatus = await myNumber.GetActivationStatus();
    
    if (myStatus.Key == ActivationStatus.STATUS_OK) {
      Console.WriteLine($"SMS code received! Code is {myStatus.Value}");
    } else {
      Console.WriteLine("SMS code was not received :( Try again later!");
    }
  }
}
Get a code from an existing number (without having a Number object)
public class Program() {
  public SMS Sms = new SMS("INSERT YOUR API KEY HERE");
  
  public async Task PrintStrangersSMS() {
    var myNumber = new Number(69420, Sms); // Where 69420 is the activation ID of the phone number 
    Console.WriteLine($"ID: {myNumber.Id} | Created at: UNKNOWN | Number: {myNumber}"); 
    // Casting a Number object to string will always return a properly formatted number (e.g +12029182132)
    // Also note that the CreatedAt field will always be null if you manually create the Number object (like in this scenario)
    
    await Task.Delay(5000); // Wait for 5 seconds (you would usually have to wait longer for an SMS)
    
    var myStatus = await myNumber.GetActivationStatus();
    
    if (myStatus.Key == ActivationStatus.STATUS_OK) {
      Console.WriteLine($"SMS code received! Code is {myStatus.Value}");
    } else {
      Console.WriteLine("SMS code was not received :( Try again later!");
    }
  }
}

Notes

An important feature that sms-activate.org has is the ability to get a number for multiple services. Sadly, during my tests and attempts at implementing it in this library, I found an issue with their API where it does not respond according to their documentation. In fact, it doesn't respond at all, which is why the method in the library is marked as obsolete. Despite my efforts to report the incident to sms-activate.org's technical support team, I've been unable to reach them and will continue to report this issue to them.

TODO

  • Add basic components
  • Add all activation endpoints
  • Add all rent endpoints
  • Add internal endpoints and document them
  • Add a method to automatically wait for an SMS to be received (with a timeout)

License

Copyright (c) 2022 Kan

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.1 1,236 3/27/2022