@@ -64,7 +64,9 @@ discard block |
||
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | public function getTicket($type = WechatOAuth::TICKETTYPE_JSAPI, $accessToken = null){ |
| 67 | - if(!$accessToken) $accessToken = $this->getAccessToken(); |
|
| 67 | + if(!$accessToken) { |
|
| 68 | + $accessToken = $this->getAccessToken(); |
|
| 69 | + } |
|
| 68 | 70 | // $url = "https://qyapi.weixin.qq.com/cgi-bin/get_jsapi_ticket?access_token=$accessToken"; |
| 69 | 71 | $url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?type={$type}&access_token=$accessToken"; |
| 70 | 72 | $this->responseJSON = $this->httpClient->get($url); |
@@ -72,7 +74,9 @@ discard block |
||
| 72 | 74 | } |
| 73 | 75 | |
| 74 | 76 | public function getSession($code,$accesstoken = null){ |
| 75 | - if(!$accesstoken) $accesstoken = $this->getAccessToken(); |
|
| 77 | + if(!$accesstoken) { |
|
| 78 | + $accesstoken = $this->getAccessToken(); |
|
| 79 | + } |
|
| 76 | 80 | $url = "https://api.weixin.qq.com/sns/jscode2session?appid={$this->appId}&secret={$this->appSecret}&js_code=$code&grant_type=authorization_code"; |
| 77 | 81 | $this->responseJSON = $this->httpClient->get($url); |
| 78 | 82 | return json_decode($this->responseJSON); |
@@ -83,7 +87,9 @@ discard block |
||
| 83 | 87 | $url = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://"; |
| 84 | 88 | $url .= "{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"; |
| 85 | 89 | } |
| 86 | - if(!$ticket) $ticket = $this->getTicket(); |
|
| 90 | + if(!$ticket) { |
|
| 91 | + $ticket = $this->getTicket(); |
|
| 92 | + } |
|
| 87 | 93 | $timestamp = time(); |
| 88 | 94 | $nonceStr = $this->getNonceStr(); |
| 89 | 95 | $rawString = "jsapi_ticket=$ticket&noncestr=$nonceStr×tamp=$timestamp&url=$url"; |
@@ -8,8 +8,11 @@ discard block |
||
| 8 | 8 | private $cacheDir = null; |
| 9 | 9 | |
| 10 | 10 | public function __construct($cacheDir = null){ |
| 11 | - if(!$cacheDir) $this->cacheDir = __DIR__; |
|
| 12 | - else $this->cacheDir = $cacheDir; |
|
| 11 | + if(!$cacheDir) { |
|
| 12 | + $this->cacheDir = __DIR__; |
|
| 13 | + } else { |
|
| 14 | + $this->cacheDir = $cacheDir; |
|
| 15 | + } |
|
| 13 | 16 | } |
| 14 | 17 | |
| 15 | 18 | public function set($key,$jsonobj,$expireAt = null){ |
@@ -18,7 +21,9 @@ discard block |
||
| 18 | 21 | $file = "{$this->cacheDir}/{$key}.json"; |
| 19 | 22 | $fp = fopen($file, "w"); |
| 20 | 23 | fwrite($fp, json_encode($data)); |
| 21 | - if ($fp) fclose($fp); |
|
| 24 | + if ($fp) { |
|
| 25 | + fclose($fp); |
|
| 26 | + } |
|
| 22 | 27 | } |
| 23 | 28 | |
| 24 | 29 | public function get($key){ |