@@ -29,8 +29,9 @@ discard block |
||
29 | 29 | if($this->timeout < 1) { |
30 | 30 | curl_setopt($this->instance, CURLOPT_NOSIGNAL,1); |
31 | 31 | curl_setopt($this->instance, CURLOPT_TIMEOUT_MS, $this->timeout * 1000); |
32 | - }else |
|
33 | - curl_setopt($this->instance, CURLOPT_TIMEOUT, intval($this->timeout)); |
|
32 | + } else { |
|
33 | + curl_setopt($this->instance, CURLOPT_TIMEOUT, intval($this->timeout)); |
|
34 | + } |
|
34 | 35 | curl_setopt($this->instance, CURLOPT_RETURNTRANSFER, true); |
35 | 36 | curl_setopt($this->instance, CURLOPT_FOLLOWLOCATION, true); |
36 | 37 | curl_setopt($this->instance, CURLOPT_SSL_VERIFYPEER, false); |
@@ -38,8 +39,12 @@ discard block |
||
38 | 39 | } |
39 | 40 | |
40 | 41 | public function get($url,$params = array(),$headers = array(),$opts = array()) { |
41 | - if (!$this->instance) $this->initInstance($this->timeout); |
|
42 | - if($params && count($params) > 0) $url .= '?' . http_build_query($params); |
|
42 | + if (!$this->instance) { |
|
43 | + $this->initInstance($this->timeout); |
|
44 | + } |
|
45 | + if($params && count($params) > 0) { |
|
46 | + $url .= '?' . http_build_query($params); |
|
47 | + } |
|
43 | 48 | curl_setopt($this->instance, CURLOPT_URL, $url); |
44 | 49 | curl_setopt($this->instance, CURLOPT_HTTPGET, true); |
45 | 50 | curl_setopt($this->instance, CURLOPT_HTTPHEADER, $headers); |
@@ -51,7 +56,9 @@ discard block |
||
51 | 56 | } |
52 | 57 | |
53 | 58 | public function post($url, $params = array(),$headers = array(),$opts = array()) { |
54 | - if (!$this->instance) $this->initInstance($this->timeout); |
|
59 | + if (!$this->instance) { |
|
60 | + $this->initInstance($this->timeout); |
|
61 | + } |
|
55 | 62 | curl_setopt($this->instance, CURLOPT_URL, $url); |
56 | 63 | curl_setopt($this->instance, CURLOPT_POST, true); |
57 | 64 | curl_setopt($this->instance, CURLOPT_POSTFIELDS, $params); |
@@ -66,7 +66,9 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | public function getTicket($type = OAuth::TICKETTYPE_JSAPI, $accessToken = null){ |
69 | - if(!$accessToken) $accessToken = $this->getAccessToken(); |
|
69 | + if(!$accessToken) { |
|
70 | + $accessToken = $this->getAccessToken(); |
|
71 | + } |
|
70 | 72 | // $url = "https://qyapi.weixin.qq.com/cgi-bin/get_jsapi_ticket?access_token=$accessToken"; |
71 | 73 | $url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?type={$type}&access_token=$accessToken"; |
72 | 74 | $this->responseJSON = $this->httpClient->get($url); |
@@ -85,7 +87,9 @@ discard block |
||
85 | 87 | (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443)) ? "https://" : "http://"; |
86 | 88 | $url .= "{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"; |
87 | 89 | } |
88 | - if(!$ticket) $ticket = $this->getTicket(); |
|
90 | + if(!$ticket) { |
|
91 | + $ticket = $this->getTicket(); |
|
92 | + } |
|
89 | 93 | $timestamp = time(); |
90 | 94 | $nonceStr = $this->getNonceStr(); |
91 | 95 | $rawString = "jsapi_ticket=$ticket&noncestr=$nonceStr×tamp=$timestamp&url=$url"; |