Adwords api:检索每日支出(成本) [英] adwords api: retrieve daily spend (costs)

查看:28
本文介绍了Adwords api:检索每日支出(成本)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有人提供一些示例代码来展示如何获取 AdWords 帐户的每日总支出(跨所有广告系列)?

Does anybody have some sample code that shows how to get the daily, total spend (across all campaigns) of an AdWords account?

我一直无法找到以直接方式执行此类操作的示例代码,因此将不胜感激任何帮助、指针和代码.(我将使用 python 库,但任何其他语言也很酷......)

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 示例 此处编写等效的 Python 代码.

You should be able to use the get_all_campaigns.py example here to write the equivalent Python code.

这篇关于Adwords api:检索每日支出(成本)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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