Signed-off-by: hitsword <mail@huayizhiyun.com>
master
hitsword 2019-05-20 16:45:23 +08:00
parent 933e90bfc2
commit dc95b73c36
1 changed files with 7 additions and 4 deletions

View File

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