Please help me to create this code to send sms through this sms gateway

Please anyone say me to create the code to send sms using this manual.

6.3. PHP
6.3.1. Installation
Find library source code from GitHub - adeonatech/PHP-SMS-API-lib and download it to your
selected path. Then call

<?php require(‘/PHP-SMS-API-lib-main/send_sms_impl.php’); ?>

inside your PHP code.
25 | P a g e Confidential – All right reserved to Dialog Axiata PLC
v
6.3.2. Quick Start
6.3.2.1. Get Access token
After sign up in https://esms.dialog.lk you must need to get access token using username, password:

  1. Create the object of “SendSMSImpl” to use method to get token:
    $sendSmsImpl = new SendSMSImpl();
  2. Set username through object:
    $tokenBody->setUsername();
  3. Set password through object:
    $tokenBody->setPassword();
  4. Create the object of “TokenBody” for set data to get token:
    $tokenBody = new TokenBody();
  5. Get token using “getToken()” method through object:
    $sendSmsImpl->getToken(<new TokenBody()>){
    return <new TokenResponse()>
    }
  6. Get “TokenResponse” type return values:
    a. Get token
    $sendSmsImpl->getToken((<new TokenBody()>)->getToken();
    b. Get comment
    $sendSmsImpl->getToken((<new TokenBody()>)->getComment();
    c. Get status
    $sendSmsImpl->getToken((<new TokenBody()>)->getStatus();
    d. Get remaining count
    $sendSmsImpl->getToken((<new TokenBody()>)->getRemainingCount();
    e. Get expiration
    26 | P a g e Confidential – All right reserved to Dialog Axiata PLC
    v
    $sendSmsImpl->getToken((<new TokenBody()>)->getExpiration();
    f. Get refresh token
    $sendSmsImpl->getToken((<new TokenBody()>)->getRefreshToken();
    g. Get refresh expiration
    $sendSmsImpl->getToken((<new TokenBody()>)->getRefreshExpiration();
    h. Get error code
    $sendSmsImpl->getToken((<new TokenBody()>)->getErrCode();
    i. Get user data
    i. Get wallet balance
    $sendSmsImpl->getToken((<new TokenBody()>)->getUderData()->getWalletBalance();
    ii. Get default mask
    $sendSmsImpl->getToken((<new TokenBody()>)->getUderData()->getDefaultMask();
    iii. Get email
    $sendSmsImpl->getToken((<new TokenBody()>)->getUderData()->getEmail();
    iv. Get mobile
    $sendSmsImpl->getToken((<new TokenBody()>)->getUderData()->getMobile();
    v. Get address
    $sendSmsImpl->getToken((<new TokenBody()>)->getUderData()->getAddress();
    vi. Get last name
    $sendSmsImpl->getToken((<new TokenBody()>)->getUderData()->getLname();
    vii. Get first name
    $sendSmsImpl->getToken((<new TokenBody()>)->getUderData()->getFname();
    viii. Get id
    $sendSmsImpl->getToken((<new TokenBody()>)->getUderData()->getId();
    ix. Get additional masks
    $sendSmsImpl->getToken((<new TokenBody()>)->getUserData()-

getAdditionalMask()[0][‘mask’]
example:
27 | P a g e Confidential – All right reserved to Dialog Axiata PLC
v
$sendSmsImpl = new SendSMSImpl();
$tokenBody = new TokenBody();
$tokenBody->setUsername("nimal”);
$tokenBody->setPassword(“Admin#67!”);
$sendTextBody = new SendTextBody();
$token = $sendSmsImpl->getToken($tokenBody)->getToken();
6.3.3. Save Access token in local memory
After getting the access token you should save it in the local memory. When call for every other
methods you should set the saved access token as a parameter to get success response.
6.3.4. Check whether the access token expired or not
When access token expired the response by
$sendSmsImpl->getToken((<new TokenBody()>)->getComment()
will be “Authentication Token Expired”. Then again get new token and save it to the local memory and
continue your process.
28 | P a g e Confidential – All right reserved to Dialog Axiata PLC
v
6.3.5. Send SMS

  1. Create the object of “SensSMSImpl” to send SMS:
    $sendSmsImpl = new SendSMSImpl();
  2. Create the object of “SendTextBody” for set data to get token:
    $sendTextBody = new SendTextBody();
  3. Set source address through object:
    $sendTextBody->setSourceAddress();
  4. Set message through object:
    $sendTextBody->setMessage();
  5. Set transaction id through object:
    $sendTextBody->setTransactionId();
  6. Set msisdns through the created object of “SendSMSImpl”:
    $sendTextBody->setMsisdn($sendSmsImpl->setMsisdns(array("<MOBILE 1>","<MOBILE 2>")));
  7. Send SMS using “sendText()” method through created object of “SendSMSImpl”:
    $sendSmsImpl->sendText(,$token){
    return
    }
  8. Get “SendTextResponse” type return values:
    a. Get comment
    $sendSmsImpl->sendText(,$token)->getComment();
    b. Get status
    $sendSmsImpl->sendText(,$token)->getStatus();
    c. Get error code
    $sendSmsImpl->sendText(,$token)->getErrCode();
    29 | P a g e Confidential – All right reserved to Dialog Axiata PLC
    v
    d. Get data
    i. Get invalid numbers
    $sendSmsImpl->sendText(,$token)->getData()->getInvalidNumbers();
    ii. Get default mask
    $sendSmsImpl->sendText(,$token)->getData()->getInvalidNumbers();
    iii. Get duplicates removed
    $sendSmsImpl->sendText(,$token)->getData()->getDuplicatesRemoved();
    iv. Get user id
    $sendSmsImpl->sendText(,$token)->getData()->getUserId();
    v. Get user mobile
    $sendSmsImpl->sendText(,$token)->getData()->getUserMobile();
    vi. Get wallet balance
    $sendSmsImpl->sendText(,$token)->getData()->getWalletBalance();
    vii. Get campaign cost
    $sendSmsImpl->sendText(,$token)->getData()->getCampaignCost();
    viii. Get campaign id
    $sendSmsImpl->sendText(,$token)->getData()->getCampaignId();
    example:
    $sendSmsImpl = new SendSMSImpl();
    $sendTextBody = new SendTextBody();
    $sendTextBody->setSourceAddress(“source1”);
    $sendTextBody->setMsisdn($sendSmsImpl-

setMsisdns(array(“71XXXXXXX”,“71XXXXXXX”)));
$sendTextBody->setTransactionId(“146”);
$sendTextBody->setMessage(“Hi this is test from PHP”);
$transactionBody = new TransactionBody();
$transactionBody->setTransactionId(“146”);
$response = $sendSmsImpl->sendText($sendTextBody, $sendSmsImpl-
getToken($tokenBody)->getToken())->getData()->getUserId();
30 | P a g e Confidential – All right reserved to Dialog Axiata PLC
v
6.3.6. Check created campaign status for a transaction id

  1. Create the object of “SendSMSImpl”:
    $sendSmsImpl = new SendSMSImpl();
  2. Create the object of “TransactionBody” for set data to get token
    $transactionBody = new TransactionBody();
  3. Set transaction id through object:
    $transactionBody->setTransactionId ();
  4. Get campaign status for the transaction id using “getTransactionIDStatus()” method
    through created object of “SendSMSImpl”:
    $sendSmsImpl->getTransactionIDStatus (, <$token>){
    return
    }
  5. Get “TransactionResponse” type return values:
    a. Get comment
    $sendSmsImpl->getTransactionIDStatus (, <$token>)->getComment();
    b. Get status
    $sendSmsImpl->getTransactionIDStatus (, <$token>)->getStatus();
    c. Get error code
    $sendSmsImpl->getTransactionIDStatus (, <$token>)->getErrCode();
    d. Get transaction id
    $sendSmsImpl->getTransactionIDStatus (, <$token>)-

getTransactionId();
e. Get data
i. Get campaign status
$sendSmsImpl->getTransactionIDStatus (, <$token>)->getData()-
getCampaignStatus();
31 | P a g e Confidential – All right reserved to Dialog Axiata PLC
v
example:
$sendSmsImpl = new SendSMSImpl();
$transactionBody = new TransactionBody();
$transactionBody->setTransactionId(“146”);
$campaignStatus = $sendSmsImpl-
getTransactionIDStatus($transactionBody, $sendSmsImpl-
getToken($tokenBody)->getToken())->getData()->getCampaignStatus()

Sponsor our Newsletter | Privacy Policy | Terms of Service