How do I add additional attributes to XML Elements with the SoapClient Class in PHP

时间秒杀一切 提交于 2019-12-06 12:25:25

Good News, I worked out how to do it.

I'm not entirely confident it's right, but it does work. And I don't quite understand how it works yet but this is what I did.

======= OLD CODE ====================
$downloadRequest = array(
"AccountIds" => array(new \SoapVar($accountId, XSD_LONG, 'xsd:long')),
"DownloadFileType" => "Tsv",
"Entities" => "Campaigns AdGroups Ads Keywords",
"PerformanceStatsDateRange" => array("PredefinedTime" => "LastFourWeeks")
"FormatVersion"  => "2.0",);

======= NEW CODE ====================
$downloadRequest = new stdClass();
$downloadRequest->AccountIds -> long = new SoapVar($accountId, XSD_LONG, 'xsd:long');
$downloadRequest->DownloadFileType = "Csv";
$downloadRequest->Entities = "Keywords";
$downloadRequest->PerformanceStatsDateRange->PredefinedTime = "LastFourWeeks";
$downloadRequest->FormatVersion = "2.0";
$downloadRequest->LastSyncTimeInUTC = new SoapVar('<ns1:LastSyncTimeInUTC xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />', XSD_ANYXML);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!