mainsms_official 1.0.7
See the version list below for details.
dotnet add package mainsms_official --version 1.0.7
NuGet\Install-Package mainsms_official -Version 1.0.7
<PackageReference Include="mainsms_official" Version="1.0.7" />
paket add mainsms_official --version 1.0.7
#r "nuget: mainsms_official, 1.0.7"
// Install mainsms_official as a Cake Addin #addin nuget:?package=mainsms_official&version=1.0.7 // Install mainsms_official as a Cake Tool #tool nuget:?package=mainsms_official&version=1.0.7
Установка
Проект собран для .NET 45 и .NET Platform Standard 1.4.
Установка из менеджера пакетов Nuget или из командной строки
PM> Install-Package MainSMS
Использование
Подключение пространства имен
using MainSms;
Ответы на запросы
Любой запрос к API, возвращает объект класса который содержит поля: | Поле | Описание |Значения| | ------ | ------ | ------ | | status | Статус выполнения запроса |success или error | | erorr | Код ошибки если статус error | Смотрите коды ошибок для вызываемого метода | | message | Описание ошибки если статус error | Смотрите описание ошибок для вызываемого метода | | response | Исходный XML ответа на API вызов | |
А так же поля доступные только для конкретного ответа на запрос, например при запросе баланса доступно поле balance.
Работа с сообщениями
SmsMessage sms = new SmsMessage(project_id, api_key);
В качестве параметра передаем project_id, api_key и если необходимо is_test и use_ssl. project_id, api_key можно получить на странице https://mainsms.ru/office/api_accounts is_test - если true то смс не будут отправляться. use_ssl - если true то будет использоваться протокол https.
Запрос баланса
ResponseBalance responseBalance = sms.getBalance();
if (responseBalance.status == "success") Console.WriteLine(responseBalance.balance);
else Console.WriteLine("Error - " + responseBalance.message);
Поля класса ResponseBalance
Поле | Описание |
---|---|
balance | Остаток средств на счете |
Расчет стоимости отправки
ResponsePrice responsePrice = sms.getMessagesPrice("sender_name", "89121231234,9121231235", "test text");
if (responsePrice.status == "success") Console.WriteLine($"Частей в одной смс {responsePrice.parts}, всего частей {responsePrice.count}, стоимость отправки {responsePrice.price}");
else Console.WriteLine("Error - " + responsePrice.message);
Поля класса ResponsePrice
Поле | Описание |
---|---|
recipients | Массив номеров получателей |
balance | Остаток средств на счете |
parts | Количество частей в одной смс |
count | Всего частей смс |
price | Стоимость отправки |
Отправка SMS сообщения
ResponseSend responseSend = sms.sendSms("sender_name", "79609701234", "test SMS message");
if (responseSend.status == "success") Console.WriteLine($"Частей в одной смс {responseSend.parts}, всего частей {responseSend.count}, стоимость отправки {responseSend.price}");
else Console.WriteLine("Error - " + responseSend.message);
Меток sendSms, может принимать в качестве четвертого параметра параметр типа DateTime, со временем на которое необходимо запланировать отправку сообщения. Время указывается в часовом поясе кабинета mainsms.ru
Поля класса ResponseSend
Поле | Описание |
---|---|
recipients | Массив номеров получателей |
messages_id | Массив идентификаторов сообщений |
balance | Остаток на средств счете |
parts | Количество частей в одной смс |
count | Всего частей смс |
price | Стоимость отправки |
test | 1 если режим тестирования и 0 если сообщения отправляются |
Product | Versions 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 | netcoreapp1.0 was computed. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard1.4 is compatible. netstandard1.5 was computed. netstandard1.6 was computed. netstandard2.0 was computed. netstandard2.1 was computed. |
.NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen30 was computed. tizen40 was computed. tizen60 was computed. |
Universal Windows Platform | uap was computed. uap10.0 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.5
- System.Net.Http (>= 4.3.4)
-
.NETStandard 1.4
- NETStandard.Library (>= 1.6.1)
- System.Net.Http (>= 4.3.4)
- System.Security.Cryptography.Algorithms (>= 4.3.0)
- System.Text.Encodings.Web (>= 4.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.