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; } }