Overview

Namespaces

  • None
  • PHP
  • tschiemer
    • Aspsms
      • Http
      • Soap
      • Xml

Classes

  • SoapClient
  • SoapSimpleClient
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: 
  3: namespace tschiemer\Aspsms\Soap;
  4: use \tschiemer\Aspsms as Aspsms;
  5: 
  6: /**
  7:  * Simple client class for SOAP driver only.
  8:  * 
  9:  * @version 1.1.0
 10:  * @package aspsms
 11:  * @license LGPL v3 http://www.gnu.org/licenses/lgpl-3.0.txt 
 12:  * @copyright 2013 Philip Tschiemer, <tschiemer@filou.se>
 13:  * @link https://github.com/tschiemer/aspsms-php
 14:  */
 15: class SoapSimpleClient extends Aspsms\AbstractSimpleClient
 16: {
 17:     /**
 18:      * @var SoapClient
 19:      */
 20:     var $driver;
 21:     
 22:     /**
 23:      * Constructor
 24:      * 
 25:      * Sets up simple client and client/driver, thus taking any parameters for these to
 26:      * where any parameters for the driver must be fields of the base field 'soapclient'
 27:      * eg
 28:      * 
 29:      *  new HttpSimpleClient(array(
 30:      *      'userkey'       => 'k',
 31:      *      'password'      => 'p',
 32:      *      'originator'    => 'o',
 33:      *      'soapclient'    => array(
 34:      *          'wsdl'  => 'http://..',
 35:      *          'soap'  => array(cache_wsdl => WSDL_CACHE_NONE,..)
 36:      *      )
 37:      *  ));
 38:      * 
 39:      * 
 40:      * @param assoc $options
 41:      * 
 42:      * @see AbstractSimpleClient::__construct()
 43:      * @see SoapClient::__construct()
 44:      */
 45:     public function __construct($options = array()) {
 46:         parent::__construct($options);
 47:         
 48:         if (!isset($options['soapclient']) or  !is_array($options['soapclient']))
 49:         {
 50:             $options['soapclient'] = array();
 51:         }
 52:         
 53:         $this->driver = new SoapClient($options['soapclient']);
 54:     }
 55:     
 56:     
 57:     /**
 58:      * Get driver for simple client.
 59:      * 
 60:      * @param \Aspsms\Request $request
 61:      * @return \Aspsms\AstractClient
 62:      */
 63:     public function driver(&$request) {
 64:         return $this->driver;
 65:     }
 66:     
 67:     
 68:     /**
 69:      * Request: Get Soap Service version.
 70:      * 
 71:      * @return array Associative array with fields 'all','version','build' and corresponding meaning.
 72:      */
 73:     public function getVersion()
 74:     {
 75:         return $this->send(array(
 76:             'RequestName' => 'getVersion'
 77:         ));
 78:     }
 79:     
 80:     
 81:     /**
 82:      * Request: Get description to given status code.
 83:      * 
 84:      * @param string|int $statusCode
 85:      * @return string
 86:      */
 87:     public function getStatusDescription($statusCode)
 88:     {   
 89:         return $this->send(array(
 90:             'RequestName' => 'getStatusCodeDescription',
 91:             'StatusCode' => $statusCode
 92:         ));
 93:     }
 94:     
 95:     
 96:     /**
 97:      * Request: Send a token a predefined token to recipients.
 98:      * 
 99:      * Official doc:
100:      * 
101:      * If MessageData is set, the placeholder <VERIFICATIONCODE> will be
102:      * substituted with the verification code. If MessageData is not defined,
103:      * or if MessageData does not contain the placeholder <VERIFICATIONCODE>,
104:      * only the verification code is sent.
105:      * 
106:      * @param string $phoneNr           Recipient phone number
107:      * @param string $reference         Your reference number
108:      * @param string $verificationCode  Required verification code to send
109:      * @param string $message           Message to send code with.
110:      * @param int $minutes              Validity of token in minutes (default 5)
111:      * @param boolean $case_sensitive   Is given code case sensitive?
112:      * @return boolean                  Request success?
113:      */
114:     public function sendMyToken($phoneNr,$reference,$verificationCode,$message='',$minutes=5, $case_sensitive=0)
115:     {
116:         return $this->send(array(
117:             'RequestName'       => 'sendToken',
118:             'Recipients'        => $phoneNr,
119:             'TokenReference'    => $reference,
120:             'VerificationCode'  => $verificationCode,
121:             'MessageData'       => $message,
122:             'TokenValidity'     => $minutes,
123:             'TokenCaseSensitive'=> $case_sensitive
124:         ));
125:     }
126:     
127:     /**
128:      * Request: Send a token as generated by ASPSMS.COM, optionally give token mask.
129:      * 
130:      * Official doc:
131:      * 
132:      * If MessageData is set, the placeholder <VERIFICATIONCODE> will be
133:      * substituted with the verification code. If MessageData is not defined,
134:      * or if MessageData does not contain the placeholder <VERIFICATIONCODE>,
135:      * only the verification code is sent.
136:      * 
137:      * Official doc:
138:      * 
139:      * Used to have the ASPSMS generate a verification code by mask. The mask can contain the following special characters:
140:      *
141:      *  # : a digit
142:      *  A : an alphabetic character
143:      *  N : an alphanumeric character
144:      *
145:      *  All other characters are taken literally. If not specified, the Mask is "NNNN" by default.
146:      *
147:      * 
148:      * @param string $phoneNr           Recipient phone number
149:      * @param string $reference         Your reference number
150:      * @param string $message           Message to send code with.
151:      * @param string $mask              Token code mask to use
152:      * @param int $minutes              Validity of token in minutes (default 5)
153:      * @param boolean $case_sensitive   Is given code case sensitive?
154:      * @return boolean                  Request success?
155:      */
156:     public function sendGeneratedToken($phoneNr,$reference,$message='',$mask='######',$minutes=5, $case_sensitive=0)
157:     {
158:         return $this->send(array(
159:             'RequestName'       => 'sendToken',
160:             'Recipients'        => $phoneNr,
161:             'TokenReference'    => $reference,
162:             'TokenMask'         => $mask,
163:             'MessageData'       => $message,
164:             'TokenValidity'     => $minutes,
165:             'TokenCaseSensitive'=> $case_sensitive
166:         ));
167:     }
168:     
169:     /**
170:      * Request: attempt to validate token.
171:      * 
172:      * NOTE: If a token have been successfully validated, any future attempts (no matter the 
173:      * verification code use) succeed.
174:      * 
175:      * @param string $phoneNr           Recipient phone number
176:      * @param string $reference         Your reference number
177:      * @param string $verificationCode  Required verification code to validate
178:      * @return boolean                  Is given verification code for use valid?
179:      */
180:     public function validateToken($phoneNr,$reference,$verificationCode)
181:     {
182:         return $this->send(array(
183:             'RequestName'       => 'verifyToken',
184:             'PhoneNumber'       => $phoneNr,
185:             'TokenReference'    => $reference,
186:             'VerificationCode'  => $verificationCode
187:         ));
188:     }
189: }
aspsms-php API documentation generated by ApiGen 2.8.0