{{:: '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> OldSendByPost( string senderNumber, List<string> numbers, string message, int? isMd5 ) { var result = await service.OldSendByPost(senderNumber, numbers, message, isMd5); 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 OldSendByPost(ByVal senderNumber As String, ByVal numbers As List(Of String), ByVal message As String, ByVal isMd5 As Integer?) As Task(Of String) Dim result = Await service.OldSendByPost(senderNumber, numbers, message, isMd5) 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 OldSendByPost( senderNumber: string, numbers: string[], message: string, isMd5?: number|null ): Promise<string> { const result = await this.service.OldSendByPost(senderNumber, numbers, message, isMd5); 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/OldSendByPost?login=[username]&pass=[password]&senderNum=[senderNumber]&recNums=[numbers]&msgBody=[message]&isMd5=null // METHODS: GET // EXAMPLE: https://niksms.com/fa/publicapi/OldSendByPost?loign=989122399413&pass=**********&senderNum=50004703&recNums=989122399413,989195059618&msgBody=salam&isMd5=1 // RESULT: