Exemple #1
0
 /**
  * @param $mobile 手机号码
  * @param $project summail project
  * @param $option  短信参数
  * @return mixed
  * @throws Exception
  */
 static function sendsms($mobile, $project, $option)
 {
     require_once PATH_LIBS . '/submail/SUBMAILAutoload.php';
     $submail = new MESSAGEXsend(PtApp::$setting['submail']['message']);
     $submail->AddTo($mobile);
     $submail->SetProject($project);
     foreach ($option as $a => $b) {
         $submail->AddVar($a, $b);
     }
     try {
         $xsend = $submail->xsend();
         if (!$xsend['status']) {
             throw new Exception('短信未发送成功,返回null');
         }
         if ($xsend['status'] == 'error') {
             throw new Exception($xsend['msg']);
         }
         return $xsend;
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
 }
|recipient cell phone number
|@Multi-para
|--------------------------------------------------------------------------
*/
$submail->AddTo('18616761881');
/*
|Optional para
|--------------------------------------------------------------------------
|set addressbook sign : Optional
|add addressbook contacts to Multi-Recipients
|@Multi-para
|--------------------------------------------------------------------------
*/
//$submail->AddAddressbook('subscribe');
/*
|Required para
|--------------------------------------------------------------------------
|set message project sign
|--------------------------------------------------------------------------
*/
$submail->SetProject('kZ9Ky3');
/*
|Optional para
|--------------------------------------------------------------------------
|submail email text content filter
|@Multi-para
|--------------------------------------------------------------------------
*/
$submail->AddVar('code', '198276');
$xsend = $submail->xsend();
print_r($xsend);
*/
$submail = new MESSAGEXsend($message_configs);
/*
|必选参数
|--------------------------------------------------------------------------
|设置短信接收的11位手机号码
|--------------------------------------------------------------------------
*/
$submail->setTo('15*********');
/*
|必选参数
|--------------------------------------------------------------------------
|设置短信模板ID
|--------------------------------------------------------------------------
*/
$submail->SetProject('xxxxx');
/*
|可选参数
|--------------------------------------------------------------------------
|添加文本变量
|可多次调用
|--------------------------------------------------------------------------
*/
$submail->AddVar('code', '198277');
/*
|调用 xsend 方法发送短信
|--------------------------------------------------------------------------
*/
$xsend = $submail->xsend();
/*
|打印服务器返回值