PHP Fatal error: Cannot use object of type stdClass as array

34 views
Skip to first unread message

s...@feedonomics.com

unread,
Mar 23, 2017, 7:25:22 PM3/23/17
to AdWords API Forum
PHP Fatal error: Cannot use object of type stdClass as array

Everything worked fine up until the update to v201702. Now we are getting: "PHP Fatal error:  Cannot use object of type stdClass as array in /.../Util/XmlDeserializer.php on line 105"

Here's the code that uses XmlDeserializer, where ConvertXmlToObject() is the part that causes the error...

if ($batchJob->downloadUrl !== null && $batchJob->downloadUrl->url !== null) {
$xmlResponse = $batchJobUtils->DownloadBatchJobResults($batchJob->downloadUrl->url);
// printf("Downloaded results from %s:\n", $batchJob->downloadUrl->url);
$deserializer = new XmlDeserializer(BatchJobUtils::$CLASS_MAP);
$mutateResponse = $deserializer->ConvertXmlToObject($xmlResponse);
if (empty($mutateResponse)) {
// printf(" No results available.\n");
} elseif (isset($mutateResponse->rval)) {
foreach ($mutateResponse->rval as $mutateResult) {
// print_r($mutateResult);
if (is_array($mutateResult)) {
$outcome = $mutateResult->errorList === null ? 'SUCCESS' : 'FAILURE';
} else {
$outcome = $mutateResult === null ? 'SUCCESS' : 'FAILURE';
}
// printf(" Operation [%d] - %s\n", $mutateResult->index, $outcome);
}
}
} else {
// printf("No results available for download.\n");
}







Ivan Bautista

unread,
Mar 23, 2017, 11:44:07 PM3/23/17
to AdWords API Forum
Hi,

Since your concern is more on the client library than the AdWords API, it would be best if you raise this issue to the client library team so they can assist you.

Regards,
Ivan 
AdWords API Team
Reply all
Reply to author
Forward
0 new messages