如何使用 PHP 访问 Square 连接错误 "detail"?

How to access Square connect error "detail" with PHP?

我正在尝试使用 PHP SDK 检索 Square API 错误对象的 detail

这是我正在使用的代码:

$err = $e->getResponseBody()->errors['0']->detail;

这行得通,但是有没有更好的方法来 return 错误消息?我已阅读文档中的 error related info,但无法找到任何代码来使用 PHP 获取 detail 属性。 谢谢!

您的想法是正确的,但您可能想使用 getDetail() 而不是 ->detail