From dc95b73c363315b01a4fb15044b8277acf3fed30 Mon Sep 17 00:00:00 2001 From: hitsword Date: Mon, 20 May 2019 16:45:23 +0800 Subject: [PATCH] debug Signed-off-by: hitsword --- includes/huayi-score-sdk.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/includes/huayi-score-sdk.php b/includes/huayi-score-sdk.php index 7de3c54..938d6c3 100644 --- a/includes/huayi-score-sdk.php +++ b/includes/huayi-score-sdk.php @@ -37,12 +37,11 @@ class HuayiScoreSdk ]; $response = $this->postRequest($url, $data); if (!$response) {//请求失败 - $this->error = '接口请求失败'; return false; - } elseif ($response['code'] == 1) {//请求成功 + } elseif ($response['body']['code'] == 1) {//请求成功 return $response; } else {//请求成功但是返回错误 - $this->error = $response['msg']; + $this->error = $response['body']['msg']; return false; } } @@ -132,9 +131,12 @@ class HuayiScoreSdk */ protected function postRequest($url, $data) { + //生成签名 + $data['signature'] = $this->getSignature($this->token, $data); + //请求接口 $response = wp_remote_post($url, array( 'method' => 'POST', - 'body' => array_merge($data, $this->getSignature($this->token, $data)), + 'body' => array_merge($data), ) ); @@ -142,6 +144,7 @@ class HuayiScoreSdk $this->error = $response->get_error_message(); return false; } else { + $response['body'] = json_decode($response['body'], true); return $response; } }