Skip to content

Commit

Permalink
Merge pull request #12 from chao/master
Browse files Browse the repository at this point in the history
修改Api.php文件,更好的兼容有赞平台返回的错误信息。
  • Loading branch information
Hanson committed May 14, 2018
2 parents 266a3be + 160a47a commit 949bf72
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ public function request($method, $params = [], $version = '3.0.0', $files = [])
$result = json_decode(strval($response->getBody()), true);

if (isset($result['error_response'])) {
throw new YouzanException($result['error_response']['msg'], $result['error_response']['code']);
// 有赞有些接口中返回的错误信息包含在msg里,有的返回message属性中。
$message = isset($result['error_response']['msg'])
? $result['error_response']['msg']
: $result['error_response']['message'];

throw new YouzanException($message, $result['error_response']['code']);
}

return $result['response'];
Expand Down

0 comments on commit 949bf72

Please sign in to comment.