新手开始使用API [英] Newbie getting started with API

查看:63
本文介绍了新手开始使用API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我刚刚开始(负责)在Perl中开发一个下载添加性能指标的脚本。 没有原生的Perl SDK,所以我不得不使用HTTP useragent进行API调用。

I have just gotten started (tasked) with developing a script, in Perl, that will download add performance metrics.  There are not native Perl SDK's, so I'm having to make my API calls using an HTTP useragent.

我不完全确定我已经获得了所有的信息,包括凭据,我需要开始使用。 把它想象成我的"Hello World"对于Bing Ads API。 ; ^)

I'm not completely sure I've been given all of the information, including credentials, that I need to get started.  Think of this as my "Hello World" for the Bing Ads API. ;^)

当我进行API调用时,我收到了这样的回复:

When I make my API call, I get this response:

============= ===============

============================

_content => < s:Envelope xmlns:s =" http://schemas.xmlsoap.org/soap/envelope/">< s:Body>< s:Fault>< faultcode xmlns:a =" http://schemas.microsoft.com/ws/2005/05/addressing/none">a:ActionNotSupported</faultcode><faultstring
xml:lang =" zh-CN">消息由于EndpointDispatcher上的ContractFilter不匹配,因此无法在接收方处理"操作"。这可能是由于合同不匹配(发件人和收件人之间的操作不匹配)或
发件人和收件人之间的绑定/安全性不匹配。 检查发送方和接收方是否具有相同的合同和相同的绑定(包括安全要求,例如消息,传输,无)。< / faultstring>< / s:Fault>< / s:Body>< / s:信封>

_content => <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><s:Fault><faultcode xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a:ActionNotSupported</faultcode><faultstring xml:lang="en-US">The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver.  Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).</faultstring></s:Fault></s:Body></s:Envelope>

============================

============================

我发送给服务器的消息(一旦插入了变量):

The message that I'm sending to the server (once variables have been interpolated) is:

============================

============================

$ message =<< EOF

< s:Envelope xmlns:i =" http://www.w3.org/2001/XMLSchema-instance" xmlns:s =" http://schemas.xmlsoap.org/soap/envelope/">

< s:Header xmlns =" https://guideads.microsoft.com / CampaignManagement / v12">

< Action mustUnderstand =" 1"> SubmitGenerateReportRequest< / Action>

< ApplicationToken i:nil =" false" > $ auth_token< / ApplicationToken>

< AuthenticationToken i:nil =" false"> $ auth_token< / AuthenticationToken>

< CustomerAccountId i:nil = " false"> $ customer_account_id< / CustomerAccountId>

< CustomerId i:nil =" false"> $ customer_account_id< / CustomerId>

< DeveloperToken i:nil =" false"> $ auth_token< / DeveloperToken>

<密码i:nil =" false"> $ auth_token< /密码>

< UserName i:nil =" false"> ***< / UserName>

< / s:Header>

< s:Body> ;
$
< SubmitGenerateReportRequest xmlns =&quo t; https://bingads.microsoft.com/CampaignManagement/v12">

< / SubmitGenerateReportRequest>
$
< / s:Body>

< / s:信封>

EOF

;

============= ===============

$message = <<EOF
<s:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header xmlns="https://bingads.microsoft.com/CampaignManagement/v12">
<Action mustUnderstand="1">SubmitGenerateReportRequest</Action>
<ApplicationToken i:nil="false">$auth_token</ApplicationToken>
<AuthenticationToken i:nil="false">$auth_token</AuthenticationToken>
<CustomerAccountId i:nil="false">$customer_account_id</CustomerAccountId>
<CustomerId i:nil="false">$customer_account_id</CustomerId>
<DeveloperToken i:nil="false">$auth_token</DeveloperToken>
<Password i:nil="false">$auth_token</Password>
<UserName i:nil="false">***</UserName>
</s:Header>
<s:Body>
<SubmitGenerateReportRequest xmlns="https://bingads.microsoft.com/CampaignManagement/v12">
</SubmitGenerateReportRequest>
</s:Body>
</s:Envelope>
EOF
;
============================

我希望提交一份"SubmitGenerateReportRequest"。致电并获取指标报告。

I'm hoping to submit a "SubmitGenerateReportRequest" call and get a metrics report.

那么,这个错误消息意味着什么,我做错了什么?

So, what does this error message mean, and what am I doing wrong?

提前致谢,

迈克。

推荐答案

其中

报告类型
你更喜欢吗?以下是 
SubmitGenerateReport  其中
报告请求类型为 
CampaignPerformanceReportRequest  (你
可以选择Csv或Tsv):

Which report type do you prefer? Here is an example of SubmitGenerateReport where the report request type is CampaignPerformanceReportRequest (you can choose Csv or Tsv):

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
	<s:Header>
		<h:ApplicationToken i:nil="true" xmlns:h="https://bingads.microsoft.com/Reporting/v12" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"/>
		<h:AuthenticationToken xmlns:h="https://bingads.microsoft.com/Reporting/v12">AccessTokenGoesHere</h:AuthenticationToken>
		<h:CustomerAccountId xmlns:h="https://bingads.microsoft.com/Reporting/v12">AccountIdGoesHere</h:CustomerAccountId>
		<h:CustomerId xmlns:h="https://bingads.microsoft.com/Reporting/v12">CustomerIdGoesHere</h:CustomerId>
		<h:DeveloperToken xmlns:h="https://bingads.microsoft.com/Reporting/v12">DeveloperTokenGoesHere</h:DeveloperToken>
		<h:Password i:nil="true" xmlns:h="https://bingads.microsoft.com/Reporting/v12" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"/>
		<h:UserName i:nil="true" xmlns:h="https://bingads.microsoft.com/Reporting/v12" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"/>
	</s:Header>
	<s:Body>
		<SubmitGenerateReportRequest xmlns="https://bingads.microsoft.com/Reporting/v12">
			<ReportRequest i:type="CampaignPerformanceReportRequest" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
				<ExcludeColumnHeaders i:nil="true"/>
				<ExcludeReportFooter i:nil="true"/>
				<ExcludeReportHeader i:nil="true"/>
				<Format>Csv</Format>
				<Language>English</Language>
				<ReportName>My Campaign Performance Report</ReportName>
				<ReturnOnlyCompleteData>false</ReturnOnlyCompleteData>
				<Aggregation>Daily</Aggregation>
				<Columns>
					<CampaignPerformanceReportColumn>TimePeriod</CampaignPerformanceReportColumn>
					<CampaignPerformanceReportColumn>AccountId</CampaignPerformanceReportColumn>
					<CampaignPerformanceReportColumn>CampaignId</CampaignPerformanceReportColumn>
					<CampaignPerformanceReportColumn>DeviceType</CampaignPerformanceReportColumn>
					<CampaignPerformanceReportColumn>BidMatchType</CampaignPerformanceReportColumn>
					<CampaignPerformanceReportColumn>QualityScore</CampaignPerformanceReportColumn>
					<CampaignPerformanceReportColumn>AdRelevance</CampaignPerformanceReportColumn>
					<CampaignPerformanceReportColumn>LandingPageExperience</CampaignPerformanceReportColumn>
					<CampaignPerformanceReportColumn>Revenue</CampaignPerformanceReportColumn>
					<CampaignPerformanceReportColumn>Assists</CampaignPerformanceReportColumn>
					<CampaignPerformanceReportColumn>ExpectedCtr</CampaignPerformanceReportColumn>
					<CampaignPerformanceReportColumn>DeliveredMatchType</CampaignPerformanceReportColumn>
					<CampaignPerformanceReportColumn>AveragePosition</CampaignPerformanceReportColumn>
					<CampaignPerformanceReportColumn>Conversions</CampaignPerformanceReportColumn>
					<CampaignPerformanceReportColumn>AdDistribution</CampaignPerformanceReportColumn>
					<CampaignPerformanceReportColumn>Network</CampaignPerformanceReportColumn>
					<CampaignPerformanceReportColumn>Clicks</CampaignPerformanceReportColumn>
					<CampaignPerformanceReportColumn>Impressions</CampaignPerformanceReportColumn>
					<CampaignPerformanceReportColumn>Ctr</CampaignPerformanceReportColumn>
					<CampaignPerformanceReportColumn>AverageCpc</CampaignPerformanceReportColumn>
					<CampaignPerformanceReportColumn>Spend</CampaignPerformanceReportColumn>
					<CampaignPerformanceReportColumn>LowQualityClicks</CampaignPerformanceReportColumn>
					<CampaignPerformanceReportColumn>LowQualityConversionRate</CampaignPerformanceReportColumn>
				</Columns>
				<Filter i:nil="true"/>
				<Scope>
					<AccountIds xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
						<a:long>AccountIdGoesHere</a:long>
					</AccountIds>
					<Campaigns i:nil="true"/>
				</Scope>
				<Time>
					<CustomDateRangeEnd i:nil="true"/>
					<CustomDateRangeStart i:nil="true"/>
					<PredefinedTime>Yesterday</PredefinedTime>
					<ReportTimeZone i:nil="true"/>
				</Time>
			</ReportRequest>
		</SubmitGenerateReportRequest>
	</s:Body>
</s:Envelope>

对于SOAPAction,您可以在没有'Request'的情况下尝试它,例如SubmitGenerateReport。在
中有一个类似的例子
此主题

我希望这有帮助,

Eric


这篇关于新手开始使用API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆