// https://api.xivdb.com/character/17803411 <-- fail
// https://api.xivdb.com/character/1395894 <-- success
function GetCharacter($url)
{
$client = new GuzzleHttp\Client();
$res = $client->get($url);
echo $res->getStatusCode();
exit();
return json_decode($res->getBody(), true);
}
在上面的代码中,当我使用成功的$ url时,我的代码工作,并且我得到状态码200.但是,当我使用$网址失败了,我刚刚得到的通用
500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed.
现在,对于失败$网址的回报,直接将它的时候是:
{ code: 404, error: "The character you are looking for could not be found. The character may still be being processed or the XIVSync service has gone down." }
我的问题是,为什么$客户端 - > get()从成功的$ url中返回JSON,但只是平坦失败的另一个?
现在行了?如果是这样,你能接受答案,请:) –