Skip to content

Instantly share code, notes, and snippets.

@zerdnem
Created November 22, 2020 03:54
Show Gist options
  • Select an option

  • Save zerdnem/3cb2da8ede6c7b9c0a0d44fd9d1a3e12 to your computer and use it in GitHub Desktop.

Select an option

Save zerdnem/3cb2da8ede6c7b9c0a0d44fd9d1a3e12 to your computer and use it in GitHub Desktop.

Revisions

  1. zerdnem created this gist Nov 22, 2020.
    79 changes: 79 additions & 0 deletions mshastra.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,79 @@
    <?php

    class Mshastra extends XtensionsSms{

    protected function sendOTP($config){
    return $this->hasSameBody($config);
    }

    protected function sendTransactional($config){
    return $this->hasSameBody($config);
    }

    private function hasSameBody($config){
    $message = $config['message'];
    $config['number'] = $this->removeLeadingZeros($config['number']);
    $number = ($config['country_code']?'+'.$config['country_code']:((isset($config['params']['countrycode_if_not_present'])?'+'.$config['params']['countrycode_if_not_present']:'+971'))).$config['number'];
    $username = isset($config['params']['username'])?$config['params']['username']:'';
    $password = isset($config['params']['password'])?$config['params']['password']:'';
    $senderid = isset($config['params']['senderid'])?$config['params']['senderid']:'';
    if($message && $number && $username && $password){
    $url = isset($config['params']['url'])?$config['params']['url']:'https://mshastra.com/sendurlcomma.aspx';
    $request = 'user=' .$username;
    $request .= '&pwd=' .$password;
    if($senderid){
    $request .= '&senderid=' .$senderid;
    }
    $request .= '&mobileno=' .$number;
    $request .= '&msgtext=' .urlencode($message);
    $request .= '&priority=High&CountryCode=ALL';
    $url = $url .'?' .$request;
    $this->log->write($url);

    $result =file_get_contents($url);
    if (empty($result)) {
    $this->log->write('xtensions sms: Blank Response');
    } else {
    $result = preg_replace( "/\r|\n/", "", $result );
    if ($result ==='Send Successful'){
    return true;
    }else{
    $this->log->write('xtensions sms has errored with Error' . $result);
    }
    }
    }
    return false;
    }

    public function adminOTP(){
    return array(
    'key' => 'mshastra',
    'title'=>'mshastra.com OTP Channel',
    'url' => 'mshastra.com',
    'type' => 'otp',
    'parameters' => array(
    'url' => 'https://mshastra.com/sendurlcomma.aspx',
    'username' => '',
    'password' => '',
    'senderid' => '',
    'countrycode_if_not_present' => '971'
    )
    );
    }

    public function adminTransactional(){
    return array(
    'key' => 'mshastra',
    'title'=>'mshastra.com Transactional Channel',
    'url' => 'mshastra.com',
    'type' => 'transactional',
    'parameters' => array(
    'url' => 'https://mshastra.com/sendurlcomma.aspx',
    'username' => '',
    'password' => '',
    'senderid' => '',
    'countrycode_if_not_present' => '971'
    )
    );
    }
    }