如何告诉 Google Adwords API 我正在查询我的 MCC 中的哪个客户/帐户?

发布于 2024-12-02 18:23:28 字数 1602 浏览 1 评论 0原文

使用最新的 PHP 客户端库(v2.6.3),我似乎无法弄清楚如何在我的 MCC(我的客户中心)帐户中获取客户的所有营销活动。

我可以通过以下方式轻松获取所有帐户:

$user = new AdWordsUser(NULL, $email, $password, $devToken, $applicationToken, $userAgent, NULL, $settingsFile);

$service = $user->GetServicedAccountService();
$selector = new ServicedAccountSelector();
$selector->enablePaging = false;

$graph = $service->get($selector);
$accounts = $graph->accounts; // all accounts!

现在我已经完成了该操作,我想获取每个帐户中的所有营销活动。按照记录运行代码 这里不起作用。

// Get the CampaignService.
// ** Different than example because example calls a private method ** //
$campaignService = $user->GetCampaignService('v201101');

// Create selector.
$selector = new Selector();
$selector->fields = array('Id', 'Name');
$selector->ordering = array(new OrderBy('Name', 'ASCENDING'));

// Get all campaigns.
$page = $campaignService->get($selector);

// Display campaigns.
if (isset($page->entries)) {
    foreach ($page->entries as $campaign) {
        print 'Campaign with name "' . $campaign->name . '" and id "'
            . $campaign->id . "\" was found.\n";
    }
}

上面的代码只会抛出一个错误:

致命错误:未捕获的 SoapFault 异常:[soap:Server] QuotaCheckError.INVALID_TOKEN_HEADER @ message=null stack=com.google.ads.api.authserver.common.AuthException 位于 com.go;

我有一种感觉,失败的原因是 GetCampaignService 需要一个帐户的 id...但我不知道如何指定这个 id。

我做错了什么?

Using the latest PHP CLient Library (v2.6.3) I can't seem to figure out to get all campaigns for a client in my MCC (my client center) account.

I can easily get all accounts via:

$user = new AdWordsUser(NULL, $email, $password, $devToken, $applicationToken, $userAgent, NULL, $settingsFile);

$service = $user->GetServicedAccountService();
$selector = new ServicedAccountSelector();
$selector->enablePaging = false;

$graph = $service->get($selector);
$accounts = $graph->accounts; // all accounts!

Now that I've done that, I want to get all the campaigns within each account. Running the code as documented here doesn't work.

// Get the CampaignService.
// ** Different than example because example calls a private method ** //
$campaignService = $user->GetCampaignService('v201101');

// Create selector.
$selector = new Selector();
$selector->fields = array('Id', 'Name');
$selector->ordering = array(new OrderBy('Name', 'ASCENDING'));

// Get all campaigns.
$page = $campaignService->get($selector);

// Display campaigns.
if (isset($page->entries)) {
    foreach ($page->entries as $campaign) {
        print 'Campaign with name "' . $campaign->name . '" and id "'
            . $campaign->id . "\" was found.\n";
    }
}

All the above code will do is throw an error:

Fatal error: Uncaught SoapFault exception: [soap:Server]
QuotaCheckError.INVALID_TOKEN_HEADER @ message=null
stack=com.google.ads.api.authserver.common.AuthException at
com.go;

I have a feeling that the reason this fails is that GetCampaignService needs an account's id...but I can't figure out how to specify this id.

What am I doing wrong?

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

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

发布评论

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

评论(1

烧了回忆取暖 2024-12-09 18:23:28

问题最终是我得到了错误的developerToken。我认为 INVALID_TOKEN_HEADER 并不真正意味着它所说的,因为某些调用仍然可以使用错误的令牌。我不知道为什么。

The problem ended up being that I was given the wrong developerToken. I didn't think INVALID_TOKEN_HEADER really meant what it said because SOME calls still worked with the faulty token. I don't know why.

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