2017-02-01 23 views
2

的「細節」當我趕上從廣場充電對象外,我與[HTTP/1.1 400 Bad Request] {"errors":[{"category":"INVALID_REQUEST_ERROR","code":"CARD_TOKEN_USED","detail":"Card nonce already used; please request new nonce."}]} 我如何提取方負責

回到我想只提取「詳細信息」傳達給用戶。我該怎麼做呢。我試過$e->getDetail()$e->getMessage()->getDetail()$e['detail']$e['errors'][0]['detail'],但沒有任何工作。我該怎麼做呢?使用php連接庫

+0

你可以這樣做: - https://eval.in/728552 –

+0

[HTTP/1.1 400 Bad請求]位之前json位打破它。我想我可以把它換算出來,但看起來這應該是更直截了當的? – PolarTheDog

+0

我沒有找到你 –

回答

1

我想通了。我正在捕捉一個標準的例外,但廣場有一個庫 - >如果你需要的答案:catch (\SquareConnect\ApiException $e) { echo $e->getResponseBody()->errors[0]->detail; }