当我尝试从 API 查看错误消息时收到此错误。文档说它在 PartialError 字段中返回一个 BatchError 对象数组。当我尝试访问 BatchError 的 Index 属性时,它给了我一个错误。怎么了?
https://msdn.microsoft.com/en-us/library/bing-ads-campaign-management-addadgroups.aspx#Anchor_1
PHP Notice – yii\base\ErrorException
Trying to get property of non-object
1. in /cygdrive/c/Users/Chloe/workspace/bestsales/models/BingAds.php at line 384
$response = $campaignProxy->GetService()->AddAdGroups($request);
} catch (\SoapFault $e) {
$this->handleException($e);
return null;
}
$adGroupsIds = $response->AdGroupIds;
$partialErrors = $response->PartialErrors;
foreach ($partialErrors as $batchError) {
Yii::error($batchError);
$adGroup = $adGroups[$batchError->Index]; # <<<<
日志:
2016-09-11 22:15:59 [::1][1][v5adqit0fiae7bon3i1lks49m3][error][application] [
unserialize('O:8:"stdClass":8:{s:4:"Code";i:1016;s:7:"Details";N;s:9:"ErrorCode";s:33:"CampaignServiceInvalidEntityState";s:9:"FieldPath";N;s:23:"ForwardCompatibilityMap";N;s:5:"Index";i:0;s:7:"Message";s:104:"Passed entity state is invalid. Please refer to documentation for list of valid values for given entity.";s:4:"Type";s:10:"BatchError";}'),
]
in /cygdrive/c/Users/Chloe/workspace/bestsales/models/BingAds.php:383
in /cygdrive/c/Users/Chloe/workspace/bestsales/models/AdGroup.php:195
in /cygdrive/c/Users/Chloe/workspace/bestsales/models/Keyword.php:145
2016-09-11 22:15:59 [::1][1][v5adqit0fiae7bon3i1lks49m3][error][yii\base\ErrorException:8] exception 'yii\base\ErrorException' with message 'Trying to get property of non-object' in /cygdrive/c/Users/Chloe/workspace/bestsales/models/BingAds.php:384
我也试过
Yii::error($batchError);
Yii::error($batchError['Index']);
Yii::error($batchError::$Index);
Yii::error($batchError->$Index);
Yii::error($batchError->Index);
我使用VarDumper
并得到了这个:
[
0 => stdClass#1
(
[Code] => 1016
[Details] => null
[ErrorCode] => 'CampaignServiceInvalidEntityState'
[FieldPath] => null
[ForwardCompatibilityMap] => null
[Index] => 0
[Message] => 'Passed entity state is invalid. Please refer to documentation for list of valid values for given entity.'
[Type] => 'BatchError'
)
]