Skip to content

Commit 66bb0ba

Browse files
authored
Merge pull request #5 from maiscrm/feat-add-jd
use exception class
2 parents a2d3c8a + b230a55 commit 66bb0ba

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

jd/JdClient.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22
namespace Jd;
33

4+
use \Exception;
5+
46
class JdClient
57
{
68
public $serverUrl = "https://api.jd.com/routerjson";
@@ -65,9 +67,8 @@ public function curl($url, $postFields = null)
6567
}
6668
}
6769
$reponse = curl_exec($ch);
68-
6970
if (curl_errno($ch)) {
70-
throw new \Exception(curl_error($ch),0);
71+
throw new Exception(curl_error($ch),0);
7172
} else {
7273
$httpStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
7374
if (200 !== $httpStatusCode) {
@@ -96,7 +97,11 @@ public function execute($request, $access_token = null)
9697
//签名
9798
$sysParams["sign"] = $this->generateSign($sysParams);
9899
//系统参数放入GET请求串
99-
$requestUrl = $this->serverUrl . "?";
100+
if (strpos($this->serverUrl, '?') !== false) {
101+
$requestUrl = $this->serverUrl . "&";
102+
} else {
103+
$requestUrl = $this->serverUrl . "?";
104+
}
100105
foreach ($sysParams as $sysParamKey => $sysParamValue) {
101106
$requestUrl .= "$sysParamKey=" . urlencode($sysParamValue) . "&";
102107
}

0 commit comments

Comments
 (0)