有没有人有一些示例代码来展示如何获得AdWords帐户的每日总支出(在所有活动中)?
我还没能找到能以简单的方式完成这项工作的示例代码,所以任何帮助、指针和代码都将不胜感激。(我会使用python库,但任何其他语言都很酷…)
提前感谢!
Hoff
我不熟悉Python,但任何语言的过程都应该相似,所以这个PHP可能会有所帮助:
$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} = $costn";
}
}
}
您应该能够在这里使用get_all_campaigns.py
示例来编写等效的Python代码。