این متد برای ارسال پیامک به صورت یک به چند می باشد یعنی یک پیامک را در یک ساعت مشخص به n شماره ارسال می کند و به تعداد n شمار�� کد پیگیری به شما باز می گرداند.

{{:: 'controllers.documentation.chooseFramework' | translate }}
PM > Install-Package NikSms.Library.Net
PM > Install-Package NikSms.Library.NetCore
using NikSms.Library.Net.WebApi; using NikSms.Library.Net.ViewModels; using System.Threading.Tasks; using System; using System.Collections.Generic; namespace AwesomeApplication { public class NikSmsApiV1Client { private readonly PublicApiV1 service; public NikSmsApiV1Client(string username, string password, string culture = "fa") { service = new PublicApiV1(username, password, culture); } public async Task<string> SendOne( string senderNumber, string number, string message, DateTime? sendOn = null, int? sendType = null, string yourMessageId = null ) { return await SendGroup(senderNumber, new List<string> { number }, message, sendOn, sendType, new List<string> { yourMessageId }); } public async Task<string> SendGroup( string senderNumber, List<string> numbers, string message, DateTime? sendOn = null, int? sendType = null, List<string> yourMessageIds = null ) { var result = await service.GroupSms(senderNumber, numbers, message, sendOn, sendType, yourMessageIds); switch (result.Status) { case LibOperationResultStatus.Success: return result.Data; case LibOperationResultStatus.InvalidModel: throw new Exception("Some required inputs are misssing..."); case LibOperationResultStatus.UnAuthorized: throw new Exception("Some thing is wrong with your account (call support!)"); case LibOperationResultStatus.Failed: throw new Exception("Ooops its our fault!"); default: throw new Exception("You sould not be here... :D"); } } } }
PM > Install-Package NikSms.Library.Net
PM > Install-Package NikSms.Library.NetCore
Imports NikSms.Library.Net.WebApi Imports NikSms.Library.Net.ViewModels Imports System.Threading.Tasks Imports System Imports System.Collections.Generic Namespace AwesomeApplication Public Class NikSmsApiV1Client Private ReadOnly service As PublicApiV1 Public Sub New(ByVal username As String, ByVal password As String, ByVal Optional culture As String = "fa") service = New PublicApiV1(username, password, culture) End Sub Public Async Function SendOne(ByVal senderNumber As String, ByVal number As String, ByVal message As String, ByVal Optional sendOn As DateTime? = Nothing, ByVal Optional sendType As Integer? = Nothing, ByVal Optional yourMessageId As String = Nothing) As Task(Of String) Return Await SendGroup(senderNumber, New List(Of String) From { number }, message, sendOn, sendType, New List(Of String) From { yourMessageId }) End Function Public Async Function SendGroup(ByVal senderNumber As String, ByVal numbers As List(Of String), ByVal message As String, ByVal Optional sendOn As DateTime? = Nothing, ByVal Optional sendType As Integer? = Nothing, ByVal Optional yourMessageIds As List(Of String) = Nothing) As Task(Of String) Dim result = Await service.GroupSms(senderNumber, numbers, message, sendOn, sendType, yourMessageIds) Select Case result.Status Case LibOperationResultStatus.Success Return result.Data Case LibOperationResultStatus.InvalidModel Throw New Exception("Some required inputs are misssing...") Case LibOperationResultStatus.UnAuthorized Throw New Exception("Some thing is wrong with your account (call support!)") Case LibOperationResultStatus.Failed Throw New Exception("Ooops its our fault!") Case Else Throw New Exception("You sould not be here... :D") End Select End Function End Class End Namespace
npm install --save niksms.library.javascript
import { ApiV1, LibOperationResultStatus } from 'niksms'; export default class NikSmsApiV1Client{ private service: ApiV1 constructor(username: string, password: string, culture: string = "fa"){ this.service = new ApiV1(username, password, culture); } public async SendOne( senderNumber: string, number: string, message: string, sendOn?: Date | null, sendType?: number | null, yourMessageId?: string ): Promise<string> { return await this.SendGroup(senderNumber, [number], message, sendOn, sendType, [yourMessageId]); } public async SendGroup( senderNumber: string, numbers: string[], message: string, sendOn?: Date | null, sendType?: number | null, yourMessageIds?: string[] ): Promise<string> { const result = await this.service.GroupSms(senderNumber, numbers, message, sendOn, sendType, yourMessageIds); switch (result.Status) { case LibOperationResultStatus.Success: return result.Data; case LibOperationResultStatus.InvalidModel: throw new Error("Some required inputs are misssing..."); case LibOperationResultStatus.UnAuthorized: throw new Error("Some thing is wrong with your account (call support!)"); case LibOperationResultStatus.Failed: throw new Error("Ooops its our fault!"); default: throw new Error("You sould not be here... :D"); } } }
// URL: https://niksms.com/fa/publicapi/GroupSMS // PAY LOAD: { "Username": "989122399413", "Password": "*********", "senderNumber": "50004307", "numbers": ["989122399413", "989195059618"], "message": "salam khoobi?" } // METHODS: GET, POST // RESULT: {"Status":8,"Id":null,"WarningMessage":null,"NikIds":null}