使用最新的PHP CLient Library(v2.6.3)我似乎無法弄清楚爲我的MCC(我的客戶中心)帳戶中的客戶獲取所有廣告系列。如何告知Google Adwords API我正在查詢的我的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!
現在,我已經做了,我想每個帳戶內的所有廣告活動。運行代碼here不起作用。
// 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";
}
}
所有上面的代碼需要做的是拋出一個錯誤:
Fatal error: Uncaught SoapFault exception: [soap:Server] QuotaCheckError.INVALID_TOKEN_HEADER @ message=null stack=com.google.ads.api.authserver.common.AuthException at com.go;
我有一種感覺,失敗的原因是,GetCampaignService需要一個帳戶的id ...但我找不出瞭解如何指定此ID。
我在做什麼錯?