python - 广告词 API : retrieve daily spend (costs)

标签 python api google-api google-ads-api

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

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

提前致谢!

霍夫

最佳答案

我不熟悉 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 示例 here编写等效的 Python 代码。

关于python - 广告词 API : retrieve daily spend (costs),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6359972/

相关文章:

python - TensorFlow - 在计算张量的平均值时忽略无限值

python - 为什么 tempfile.NamedTemporaryFile() 会截断我的数据?

json - 大型 Json 文件批量发送至 HubSpot API

youtube - 来自Google+ ID的YouTube channel

api - Blogger Api V3 中的分页

http - 'GoogleHttpClient.send'('Future<StreamedResponse> Function(BaseRequest)')不是 'IOClient.send'的有效替代

python - 如何在python中优化如下代码?

python:如何为3个子图设置相同的颜色图

php - Paypal 未继续接收付款

javascript - 如何从 API 请求