@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | private $ServerIP; |
| 23 | 23 | private $ServerPort; |
| 24 | 24 | private $SoftVersion; |
| 25 | - private $Batch; //时间戳 |
|
| 25 | + private $Batch; //时间戳 |
|
| 26 | 26 | private $BodyType = 'json'; //包体格式,可填值:json 、xml |
| 27 | 27 | |
| 28 | 28 | public function __construct(array $config, $BodyType = 'json') |
@@ -123,27 +123,27 @@ discard block |
||
| 123 | 123 | if ($this->BodyType === 'json') { |
| 124 | 124 | $data = ''; |
| 125 | 125 | for ($i = 0; $i < count($datas); $i++) { |
| 126 | - $data = $data."'".$datas[$i]."',"; |
|
| 126 | + $data = $data . "'" . $datas[$i] . "',"; |
|
| 127 | 127 | } |
| 128 | - $body = "{'to':'$to','templateId':'$tempId','appId':'$this->AppId','datas':[".$data.']}'; |
|
| 128 | + $body = "{'to':'$to','templateId':'$tempId','appId':'$this->AppId','datas':[" . $data . ']}'; |
|
| 129 | 129 | } else { |
| 130 | 130 | $data = ''; |
| 131 | 131 | for ($i = 0; $i < count($datas); $i++) { |
| 132 | - $data = $data.'<data>'.$datas[$i].'</data>'; |
|
| 132 | + $data = $data . '<data>' . $datas[$i] . '</data>'; |
|
| 133 | 133 | } |
| 134 | 134 | $body = "<TemplateSMS> |
| 135 | 135 | <to>$to</to> |
| 136 | 136 | <appId>$this->AppId</appId> |
| 137 | 137 | <templateId>$tempId</templateId> |
| 138 | - <datas>".$data.'</datas> |
|
| 138 | + <datas>" . $data . '</datas> |
|
| 139 | 139 | </TemplateSMS>'; |
| 140 | 140 | } |
| 141 | 141 | // 大写的sig参数 |
| 142 | - $sig = strtoupper(md5($this->AccountSid.$this->AccountToken.$this->Batch)); |
|
| 142 | + $sig = strtoupper(md5($this->AccountSid . $this->AccountToken . $this->Batch)); |
|
| 143 | 143 | // 生成请求URL |
| 144 | 144 | $url = "https://$this->ServerIP:$this->ServerPort/$this->SoftVersion/Accounts/$this->AccountSid/SMS/TemplateSMS?sig=$sig"; |
| 145 | 145 | // 生成授权:主帐户Id + 英文冒号 + 时间戳。 |
| 146 | - $authen = base64_encode($this->AccountSid.':'.$this->Batch); |
|
| 146 | + $authen = base64_encode($this->AccountSid . ':' . $this->Batch); |
|
| 147 | 147 | // 生成包头 |
| 148 | 148 | $header = ["Accept:application/$this->BodyType", "Content-Type:application/$this->BodyType;charset=utf-8", "Authorization:$authen"]; |
| 149 | 149 | // 发送请求 |
@@ -201,11 +201,11 @@ discard block |
||
| 201 | 201 | </VoiceVerify>"; |
| 202 | 202 | } |
| 203 | 203 | // 大写的sig参数 |
| 204 | - $sig = strtoupper(md5($this->AccountSid.$this->AccountToken.$this->Batch)); |
|
| 204 | + $sig = strtoupper(md5($this->AccountSid . $this->AccountToken . $this->Batch)); |
|
| 205 | 205 | // 生成请求URL |
| 206 | 206 | $url = "https://$this->ServerIP:$this->ServerPort/$this->SoftVersion/Accounts/$this->AccountSid/Calls/VoiceVerify?sig=$sig"; |
| 207 | 207 | // 生成授权:主帐户Id + 英文冒号 + 时间戳。 |
| 208 | - $authen = base64_encode($this->AccountSid.':'.$this->Batch); |
|
| 208 | + $authen = base64_encode($this->AccountSid . ':' . $this->Batch); |
|
| 209 | 209 | // 生成包头 |
| 210 | 210 | $header = ["Accept:application/$this->BodyType", "Content-Type:application/$this->BodyType;charset=utf-8", "Authorization:$authen"]; |
| 211 | 211 | // 发送请求 |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | public function boot() |
| 20 | 20 | { |
| 21 | 21 | $this->publishes([ |
| 22 | - __DIR__.'/../config/sms.php' => config_path('sms.php'), |
|
| 22 | + __DIR__ . '/../config/sms.php' => config_path('sms.php'), |
|
| 23 | 23 | ]); |
| 24 | 24 | } |
| 25 | 25 | |
@@ -31,10 +31,10 @@ discard block |
||
| 31 | 31 | public function register() |
| 32 | 32 | { |
| 33 | 33 | $this->mergeConfigFrom( |
| 34 | - __DIR__.'/../config/sms.php', 'sms' |
|
| 34 | + __DIR__ . '/../config/sms.php', 'sms' |
|
| 35 | 35 | ); |
| 36 | 36 | |
| 37 | - $this->app->singleton('Sms', function ($app) { |
|
| 37 | + $this->app->singleton('Sms', function($app) { |
|
| 38 | 38 | $app = new Sms(config('sms.default')); |
| 39 | 39 | |
| 40 | 40 | return $app; |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | //处理key |
| 33 | 33 | if (strpos($kk, '#') === false) { |
| 34 | - $key = '#'.$kk.'#'; |
|
| 34 | + $key = '#' . $kk . '#'; |
|
| 35 | 35 | } else { |
| 36 | 36 | $key = $kk; |
| 37 | 37 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | $value = urlencode($vv); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - $data = $data.$key.'='.$value.'&'; |
|
| 45 | + $data = $data . $key . '=' . $value . '&'; |
|
| 46 | 46 | } |
| 47 | 47 | $data = trim($data, '&'); |
| 48 | 48 | //生成query params |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | $header = ["Accept:application/$this->BodyType", "Content-Type:application/$this->BodyType;charset=utf-8"]; |
| 52 | 52 | // 生成请求URL |
| 53 | 53 | $query = http_build_query($body); |
| 54 | - $url = 'http://v.juhe.cn/sms/send?'.$query; |
|
| 54 | + $url = 'http://v.juhe.cn/sms/send?' . $query; |
|
| 55 | 55 | // 发送请求 |
| 56 | 56 | $result = $this->curl_post($url, $body, $header, 0); |
| 57 | 57 | |
@@ -122,11 +122,11 @@ |
||
| 122 | 122 | public function send() |
| 123 | 123 | { |
| 124 | 124 | if ($this->config === 'YunTongXun') { |
| 125 | - $rest = new Rest(config('sms.agents.'.$this->config)); |
|
| 125 | + $rest = new Rest(config('sms.agents.' . $this->config)); |
|
| 126 | 126 | |
| 127 | 127 | return $rest->sendTemplateSMS($this->smsData['to'], $this->smsData['templateData'], $this->smsData['templates']['YunTongXun']); |
| 128 | 128 | } elseif ($this->config === 'Juhe') { |
| 129 | - $rest = new Juhe(config('sms.agents.'.$this->config)); |
|
| 129 | + $rest = new Juhe(config('sms.agents.' . $this->config)); |
|
| 130 | 130 | |
| 131 | 131 | return $rest->sendTemplateSMS($this->smsData['to'], $this->smsData['templateData'], $this->smsData['templates']['Juhe']); |
| 132 | 132 | } else { |