@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | $this->scope = $scope; |
| 166 | 166 | } elseif ($scope === "snsapi_userinfo") { |
| 167 | 167 | $this->scope = $scope; |
| 168 | - } else { |
|
| 168 | + }else { |
|
| 169 | 169 | throw new DtaException("请检查scope参数"); |
| 170 | 170 | } |
| 171 | 171 | return $this; |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | // 获取数据 |
| 314 | 314 | $accessToken = $this->getAccessToken(); |
| 315 | 315 | if (!isset($accessToken['access_token'])) { |
| 316 | - throw new DtaException("获取access_token错误," . $accessToken['errmsg']); |
|
| 316 | + throw new DtaException("获取access_token错误,".$accessToken['errmsg']); |
|
| 317 | 317 | } |
| 318 | 318 | $res = HttpService::instance() |
| 319 | 319 | ->url("{$this->api_url}cgi-bin/ticket/getticket?access_token={$accessToken['access_token']}&type=jsapi") |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | // 获取数据 |
| 323 | 323 | $accessToken = $this->getAccessToken(); |
| 324 | 324 | if (!isset($accessToken['access_token'])) { |
| 325 | - throw new DtaException("获取access_token错误," . $accessToken['errmsg']); |
|
| 325 | + throw new DtaException("获取access_token错误,".$accessToken['errmsg']); |
|
| 326 | 326 | } |
| 327 | 327 | $res = HttpService::instance() |
| 328 | 328 | ->url("{$this->api_url}cgi-bin/ticket/getticket?access_token={$accessToken['access_token']}&type=jsapi") |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; |
| 356 | 356 | $str = ""; |
| 357 | 357 | for ($i = 0; $i < $length; $i++) { |
| 358 | - $str .= $chars[random_int(0, strlen($chars) - 1)]; |
|
| 358 | + $str .= $chars[random_int(0, strlen($chars)-1)]; |
|
| 359 | 359 | } |
| 360 | 360 | return $str; |
| 361 | 361 | } |
@@ -627,22 +627,22 @@ discard block |
||
| 627 | 627 | $accessToken_res = HttpService::instance() |
| 628 | 628 | ->url("{$this->api_url}cgi-bin/token?grant_type={$this->grant_type}&appid={$this->app_id}&secret={$this->app_secret}") |
| 629 | 629 | ->toArray(); |
| 630 | - $accessToken_res['expires_time'] = time() + 6000; |
|
| 630 | + $accessToken_res['expires_time'] = time()+6000; |
|
| 631 | 631 | file_put_contents($file, json_encode($accessToken_res, JSON_UNESCAPED_UNICODE)); |
| 632 | 632 | $accessToken = $accessToken_res; |
| 633 | - } else if (!isset($accessToken['access_token'])) { |
|
| 633 | + }else if (!isset($accessToken['access_token'])) { |
|
| 634 | 634 | // 内容不存在 |
| 635 | 635 | $accessToken_res = HttpService::instance() |
| 636 | 636 | ->url("{$this->api_url}cgi-bin/token?grant_type={$this->grant_type}&appid={$this->app_id}&secret={$this->app_secret}") |
| 637 | 637 | ->toArray(); |
| 638 | - $accessToken_res['expires_time'] = time() + 6000; |
|
| 638 | + $accessToken_res['expires_time'] = time()+6000; |
|
| 639 | 639 | file_put_contents($file, json_encode($accessToken_res, JSON_UNESCAPED_UNICODE)); |
| 640 | 640 | $accessToken = $accessToken_res; |
| 641 | - } else if ($accessToken['expires_time'] <= time()) { |
|
| 641 | + }else if ($accessToken['expires_time'] <= time()) { |
|
| 642 | 642 | $accessToken_res = HttpService::instance() |
| 643 | 643 | ->url("{$this->api_url}cgi-bin/token?grant_type={$this->grant_type}&appid={$this->app_id}&secret={$this->app_secret}") |
| 644 | 644 | ->toArray(); |
| 645 | - $accessToken_res['expires_time'] = time() + 6000; |
|
| 645 | + $accessToken_res['expires_time'] = time()+6000; |
|
| 646 | 646 | file_put_contents($file, json_encode($accessToken_res, JSON_UNESCAPED_UNICODE)); |
| 647 | 647 | $accessToken = $accessToken_res; |
| 648 | 648 | } |
@@ -654,15 +654,15 @@ discard block |
||
| 654 | 654 | $accessToken_res = HttpService::instance() |
| 655 | 655 | ->url("{$this->api_url}cgi-bin/token?grant_type={$this->grant_type}&appid={$this->app_id}&secret={$this->app_secret}") |
| 656 | 656 | ->toArray(); |
| 657 | - $accessToken_res['expires_time'] = time() + 6000; |
|
| 657 | + $accessToken_res['expires_time'] = time()+6000; |
|
| 658 | 658 | file_put_contents($file, json_encode($accessToken_res, JSON_UNESCAPED_UNICODE)); |
| 659 | 659 | $accessToken = $accessToken_res; |
| 660 | 660 | } |
| 661 | - } else { |
|
| 661 | + }else { |
|
| 662 | 662 | $accessToken_res = HttpService::instance() |
| 663 | 663 | ->url("{$this->api_url}cgi-bin/token?grant_type={$this->grant_type}&appid={$this->app_id}&secret={$this->app_secret}") |
| 664 | 664 | ->toArray(); |
| 665 | - $accessToken_res['expires_time'] = time() + 6000; |
|
| 665 | + $accessToken_res['expires_time'] = time()+6000; |
|
| 666 | 666 | file_put_contents($file, json_encode($accessToken_res, JSON_UNESCAPED_UNICODE)); |
| 667 | 667 | $accessToken = $accessToken_res; |
| 668 | 668 | } |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | $cache_mysql_value = dtacache($file); |
| 678 | 678 | if (!empty($cache_mysql_value)) { |
| 679 | 679 | $access_token['access_token'] = $cache_mysql_value; |
| 680 | - } else { |
|
| 680 | + }else { |
|
| 681 | 681 | // 获取远程Token |
| 682 | 682 | $accessToken_res = HttpService::instance() |
| 683 | 683 | ->url("{$this->api_url}cgi-bin/token?grant_type={$this->grant_type}&appid={$this->app_id}&secret={$this->app_secret}") |
@@ -749,11 +749,11 @@ discard block |
||
| 749 | 749 | // 转成字符串 |
| 750 | 750 | $stringA = Urls::toParams($array); |
| 751 | 751 | // 在字符串接商户支付秘钥 |
| 752 | - $stringSignTemp = "{$stringA}&key=" . $this->mch_key; |
|
| 752 | + $stringSignTemp = "{$stringA}&key=".$this->mch_key; |
|
| 753 | 753 | //步骤四:MD5或HMAC-SHA256C加密 |
| 754 | 754 | if ($hmacsha256) { |
| 755 | 755 | $str = hash_hmac("sha256", $stringSignTemp, $this->mch_key); |
| 756 | - } else { |
|
| 756 | + }else { |
|
| 757 | 757 | $str = md5($stringSignTemp); |
| 758 | 758 | } |
| 759 | 759 | //符转大写 |
@@ -773,8 +773,8 @@ discard block |
||
| 773 | 773 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); |
| 774 | 774 | |
| 775 | 775 | //试试手气新增,增加之后 curl 不报 60# 错误,可以请求到微信的响应 |
| 776 | - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //不验证 SSL 证书 |
|
| 777 | - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);//不验证 SSL 证书域名 |
|
| 776 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //不验证 SSL 证书 |
|
| 777 | + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); //不验证 SSL 证书域名 |
|
| 778 | 778 | //post提交方式 |
| 779 | 779 | curl_setopt($ch, CURLOPT_POST, TRUE); |
| 780 | 780 | curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); |
@@ -788,6 +788,6 @@ discard block |
||
| 788 | 788 | |
| 789 | 789 | $error = curl_errno($ch); |
| 790 | 790 | curl_close($ch); |
| 791 | - return "curl error, error code " . $error; |
|
| 791 | + return "curl error, error code ".$error; |
|
| 792 | 792 | } |
| 793 | 793 | } |