Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions jd/JdClient.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
namespace Jd;

use \Exception;

class JdClient
{
public $serverUrl = "https://api.jd.com/routerjson";
Expand Down Expand Up @@ -65,9 +67,8 @@ public function curl($url, $postFields = null)
}
}
$reponse = curl_exec($ch);

if (curl_errno($ch)) {
throw new \Exception(curl_error($ch),0);
throw new Exception(curl_error($ch),0);
} else {
$httpStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (200 !== $httpStatusCode) {
Expand Down Expand Up @@ -96,7 +97,11 @@ public function execute($request, $access_token = null)
//签名
$sysParams["sign"] = $this->generateSign($sysParams);
//系统参数放入GET请求串
$requestUrl = $this->serverUrl . "?";
if (strpos($this->serverUrl, '?') !== false) {
$requestUrl = $this->serverUrl . "&";
} else {
$requestUrl = $this->serverUrl . "?";
}
foreach ($sysParams as $sysParamKey => $sysParamValue) {
$requestUrl .= "$sysParamKey=" . urlencode($sysParamValue) . "&";
}
Expand Down