AdWords API的:获取每日支出(成本) [英] adwords api: retrieve daily spend (costs)
问题描述
没有任何人有一些样本code,说明如何获得AdWords帐户的每日总支出(所有广告系列)?
Does anybody have some sample code that shows how to get the daily, total spend (across all campaigns) of an AdWords account?
我一直没能找到样本code,做这样的事情在一个简单的方式,所以任何帮助,指针,code将AP preciated。 (我会使用Python lib目录,但任何其他语言,很酷,太...)
I haven't been able to find sample code that does something like this in a straightforward manner, so any help, pointers,code would be appreciated. (I'll use the python lib but any other language is cool, too...)
在此先感谢!
霍夫
推荐答案
我不熟悉Python,但这个过程应该是在任何语言相似,所以这个PHP可能会有所帮助:
I'm not familiar with Python but the process should be similar in any language so this PHP might be of some help:
$user = new AdWordsUser();
// Get the CampaignService.
$campaignService = $user->GetCampaignService('v201101');
// Create selector.
$selector = new Selector();
// Fields to retrieve
$selector->fields = array('Id', 'Name', 'Cost');
// Date rage for stats
$selector->dateRange->min = "20110613";
$selector->dateRange->max = "20110614";
// Get all campaigns.
$page = $campaignService->get($selector);
if(isset($page->entries)){
foreach ($page->entries as $campaign) {
if(isset($campaign->campaignStats)) {
// This is how you get the cost
$cost = $campaign->campaignStats->cost->microAmount/1000000;
print "Cost for Campaign {$campaign->name} = $cost\n";
}
}
}
您应该可以使用 get_all_campaigns.py
例如<一个href=\"http://$c$c.google.com/p/google-api-adwords-python-lib/source/browse/trunk/examples/adspygoogle/adwords/v201101/get_all_campaigns.py\"相对=nofollow>这里写的Python相当于code。
You should be able to use the get_all_campaigns.py
example here to write the equivalent Python code.
这篇关于AdWords API的:获取每日支出(成本)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!