自从 Savon gem 将 Ruby 代码转换为 XML 以来,我已经能够在不了解 XML 的情况下做到这一点,但现在我被困住了。我从 API 请求 CampaignPerformanceReport 并且能够成功检索我需要的数据,但现在我需要添加一个过滤器以仅获取“暂停”广告系列。
按照此文档,我将此消息发送到 API:
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="https://bingads.microsoft.com/Reporting/v13" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns="https://bingads.microsoft.com/Reporting/v13">
<env:Header>
<AuthenticationToken>foo</AuthenticationToken>
<CustomerAccountId>foo</CustomerAccountId>
<CustomerId>foo</CustomerId>
<DeveloperToken>foo</DeveloperToken>
</env:Header>
<env:Body>
<tns:SubmitGenerateReportRequest>
<ReportRequest xsi:nil="false" xsi:type="CampaignPerformanceReportRequest">
<ExcludeColumnHeaders>true</ExcludeColumnHeaders>
<ExcludeReportFooter>true</ExcludeReportFooter>
<ExcludeReportHeader>true</ExcludeReportHeader>
<Format>Csv</Format>
<Language>English</Language>
<ReportName>CampaignPerformanceReportRequest</ReportName>
<ReturnOnlyCompleteData>false</ReturnOnlyCompleteData>
<Aggregation>Summary</Aggregation>
<Columns>
<CampaignPerformanceReportColumn>CampaignName</CampaignPerformanceReportColumn>
<CampaignPerformanceReportColumn>CampaignStatus</CampaignPerformanceReportColumn>
<CampaignPerformanceReportColumn>Spend</CampaignPerformanceReportColumn>
<CampaignPerformanceReportColumn>Impressions</CampaignPerformanceReportColumn>
<CampaignPerformanceReportColumn>Clicks</CampaignPerformanceReportColumn>
<CampaignPerformanceReportColumn>Conversions</CampaignPerformanceReportColumn>
<CampaignPerformanceReportColumn>Revenue</CampaignPerformanceReportColumn>
<CampaignPerformanceReportColumn>PhoneCalls</CampaignPerformanceReportColumn>
</Columns>
<Filter>
<CampaignStatusReportFilter>Paused</CampaignStatusReportFilter>
</Filter>
<Scope>
<AccountIds xmlns:a1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a1:long>foo</a1:long>
</AccountIds>
</Scope>
<Time>
<CustomDateRangeEnd>
<Day>31</Day>
<Month>01</Month>
<Year>2019</Year>
</CustomDateRangeEnd>
<CustomDateRangeStart>
<Day>01</Day>
<Month>01</Month>
<Year>2019</Year>
</CustomDateRangeStart>
<PredefinedTime xsi:nil="true"/>
<ReportTimeZone>EasternTimeUSCanada</ReportTimeZone>
</Time>
</ReportRequest>
</tns:SubmitGenerateReportRequest>
</env:Body>
</env:Envelope>
请求被接受并处理,但返回的数据仅显示“活动”活动。我确定我的过滤方式存在问题。这是我用来生成请求的 Ruby 代码。
report_request = {
'@xsi:nil' => false,
'@xsi:type' => 'CampaignPerformanceReportRequest',
'ExcludeColumnHeaders' => true,
'ExcludeReportFooter' => true,
'ExcludeReportHeader' => true,
'Format' => 'Csv',
'Language' => 'English',
'ReportName' => 'CampaignPerformanceReportRequest',
'ReturnOnlyCompleteData' => false,
'Aggregation' => 'Summary',
'Columns' => {
'CampaignPerformanceReportColumn' => [
'CampaignName',
'CampaignStatus',
'Spend',
'Impressions',
'Clicks',
'Conversions',
'Revenue',
'PhoneCalls'
]
},
'Filter' => { 'CampaignStatusReportFilter' => 'Paused' },
'Scope' => {
'AccountIds' => {
'@xmlns:a1' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays',
'a1:long' => account_id,
}
},
etc...
}
我已经尝试完全匹配上面链接到的文档中的语法,但它仍然只返回“活动”活动,这让我相信这是默认设置,API 只是忽略了我不正确的过滤。
如果有人可以帮助我弄清楚我在这里做错了什么,将不胜感激。