Php 如果;讯息;是受保护的,如何检索名为;“消息?”;?
我真的被这件事难住了。在这篇文章的底部,我附上了我正在使用的API文档。当回答(“询问”)不是“成功”时,我想抓住“信息”。看起来很合理,对吧?但是当我做一些类似的事情时:Php 如果;讯息;是受保护的,如何检索名为;“消息?”;?,php,soap,Php,Soap,我真的被这件事难住了。在这篇文章的底部,我附上了我正在使用的API文档。当回答(“询问”)不是“成功”时,我想抓住“信息”。看起来很合理,对吧?但是当我做一些类似的事情时: sfcSendError('Something went wrong. This is the message from the API: ' . $result->message); 我得到一个致命错误: PHP Fatal error: Cannot access protected property SoapF
sfcSendError('Something went wrong. This is the message from the API: ' . $result->message);
我得到一个致命错误:
PHP Fatal error: Cannot access protected property SoapFault::$message
我找到了,所以我尝试将“message”更改为“getMessage()”,但(毫不奇怪)这会导致调用未定义函数时出现另一个致命错误
以下是我的代码片段:
$client = mySoapClient(MODULE_SHIPPING_SFC_API_URL);
if (!$client) {
sfcSendError('could not make a SOAP connection. Halting until next CRON. [' . __FILE__ . ':' . __LINE__ . ']', 'SOAP Failure in cron job');
exit; //halt and wait for the next time cron runs
} else {
$HeaderRequest = array(
'customerId' => MODULE_SHIPPING_SFC_ACCOUNT,
'appToken' => MODULE_SHIPPING_SFC_TOKEN,
'appKey' => MODULE_SHIPPING_SFC_KEY
);
$reg = array(
'HeaderRequest' => $HeaderRequest,
'detailLevel' => 1,
'ordersCode' => $_query->fields['sfc_ordersCode']
);
$result = $client->getOrderByCode($reg);
if ($result->ask != "Success") {
sfcSendError('Something went wrong. This is the message from SFC: ' . $result->message, 'SOAP Failure in cron job');
$_query->MoveNext();
continue;
}
}
这是引用的函数:
function mySoapClient($url)
{
try {
$client = @new SoapClient($url, array(
'trace' => 1,
'exceptions' => 0,
'encoding' => 'UTF-8'
));
} catch (SoapFault $e) {
return 0;
}
return $client;
}
我做错了什么?或者这是API中的一个“bug”,他们真的不应该在响应中使用“消息”
提供指向类mySoapClient()的链接;或者在类中导航并搜索可以找到的方法:
return$this->message代码>提供指向类mySoapClient()的链接;或者在类中导航并搜索可以找到的方法:return$this->message代码>