adwords api:检索每日支出(费用)

发布于 2024-11-15 14:13:50 字数 155 浏览 3 评论 0原文

有人有一些示例代码来说明如何获取 AdWords 帐户的每日总支出(所有广告系列)吗?

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

提前致谢!

霍夫

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

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...)

Thanks in advance!

Hoff

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暖风昔人 2024-11-22 14:13:50

我不熟悉 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} = $cost\n";
        }
    }
}

您应该能够使用 get_all_campaigns.py 示例 此处 编写等效的 Python 代码。

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";
        }
    }
}

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文