@@ -67,9 +67,9 @@ |
||
| 67 | 67 | * @param string $url |
| 68 | 68 | * @param mixed $data |
| 69 | 69 | * @param mixed $header |
| 70 | - * @param mixed $post |
|
| 70 | + * @param integer $post |
|
| 71 | 71 | * |
| 72 | - * @return mixed |
|
| 72 | + * @return string |
|
| 73 | 73 | */ |
| 74 | 74 | public function curl_post($url, $data, $header, $post = 1) |
| 75 | 75 | { |
@@ -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; |
@@ -122,7 +122,7 @@ |
||
| 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 | } else { |