Skip to content

Commit 860743f

Browse files
committed
修复bug;curl组件 发送后清空head头,报错的信息获取
1 parent 0d4636c commit 860743f

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"ext-bcmath": "*",
1717
"ext-curl": "*",
1818
"ext-simplexml": "*",
19-
"ext-libxml": "*"
19+
"ext-libxml": "*",
20+
"ext-xml": "*"
2021
},
2122
"autoload": {
2223
"psr-4": {

src/siam/Curl.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,17 @@ public function send($url, $data = null, $cert = [], $post = true)
9292
if (!empty($this->head)){
9393
curl_setopt($curl, CURLOPT_HEADER, 0);
9494
curl_setopt($curl, CURLOPT_HTTPHEADER, $this->head);
95+
$this->setHead([]);
9596
}
9697

9798
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
9899
$response = curl_exec($curl); // 执行一个cURL会话并且获取相关回复
99100

100101
if ($response === false) {
102+
$error = curl_error($curl);
103+
$errno = curl_errno($curl);
101104
curl_close($curl); // 释放cURL句柄,关闭一个cURL会话
102-
throw new \Exception("[". curl_errno($curl) . "]" . curl_error($curl));
105+
throw new \Exception("[". $errno . "]" . $error);
103106
}
104107

105108
$this->responseHead = curl_getinfo($curl);

src/siam/Wechat/Work.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class Work
1414
{
1515
use Singleton;
1616

17+
private $lastData;
18+
1719
private function __construct($config = [])
1820
{
1921
empty($config['key']) or $this->key = $config['key'];
@@ -176,7 +178,7 @@ public function getOpenid($config = null)
176178
curl_close($ch);
177179
$openid = json_decode($res, true);
178180

179-
if (!isset($openid['openid])){
181+
if (!isset($openid['openid'])){
180182
$this->lastData = $openid;
181183
return false;
182184
}
@@ -210,6 +212,7 @@ public function decryption($data = array())
210212
* 调用get一般场景【微信回调拿到的金额转换为分单位存到数据库】 微信回调1日元 = 100分 转成分单位 乘以100
211213
* @param $total_fee
212214
* @param $fee_type
215+
* @param string $type
213216
* @return string|int
214217
*/
215218
public function checkFeeType($total_fee, $fee_type, $type = 'set')

0 commit comments

Comments
 (0)