我正在使用 google adwords api,我可以检索所有广告系列、组广告、广告,但我不知道如何检索与“组广告”相关的关键字。在 google adwords 界面中,当我们选择一个组广告时,我们有两个选项卡,一个用于与该组广告相关的广告,第二个用于关键字。但是以编程方式,现在我只能检索广告。我正在使用 PHP,如果有人知道如何用 php 或其他编程语言甚至是肥皂调用来做到这一点。
问问题
9521 次
2 回答
6
要获取广告组的所有关键字的详细信息,您需要以下内容来获取所有关键字的详细信息。
require_once dirname(dirname(__FILE__)) . '/init.php';
// Enter parameters required by the code example.
$adGroupId = 'Enter your adgroup id';
/**
* Runs the example.
* @param AdWordsUser $user the user to run the example with
* @param string $adGroupId the id of the parent ad group
*/
function GetKeywordsExample(AdWordsUser $user, $adGroupId) {
// Get the service, which loads the required classes.
$adGroupCriterionService =
$user->GetService('AdGroupCriterionService', ADWORDS_VERSION);
// Create selector.
$selector = new Selector();
$selector->fields = array('KeywordText', 'KeywordMatchType', 'Id');
$selector->ordering[] = new OrderBy('KeywordText', 'ASCENDING');
// Create predicates.
$selector->predicates[] = new Predicate('AdGroupId', 'IN', array($adGroupId));
$selector->predicates[] =
new Predicate('CriteriaType', 'IN', array('KEYWORD'));
// Create paging controls.
$selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
do {
// Make the get request.
$page = $adGroupCriterionService->get($selector);
// Display results.
if (isset($page->entries)) {
foreach ($page->entries as $adGroupCriterion) {
printf("Keyword with text '%s', match type '%s', and ID '%s' was "
. "found.\n", $adGroupCriterion->criterion->text,
$adGroupCriterion->criterion->matchType,
$adGroupCriterion->criterion->id);
}
} else {
print "No keywords were found.\n";
}
// Advance the paging index.
$selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
} while ($page->totalNumEntries > $selector->paging->startIndex);
}
// Don't run the example if the file is being included.
if (__FILE__ != realpath($_SERVER['PHP_SELF'])) {
return;
}
try {
// Get AdWordsUser from credentials in "../auth.ini"
// relative to the AdWordsUser.php file's directory.
$user = new AdWordsUser();
// Log every SOAP XML request and response.
$user->LogAll();
// Run the example.
GetKeywordsExample($user, $adGroupId);
} catch (Exception $e) {
printf("An error has occurred: %s\n", $e->getMessage());
}
于 2015-02-12T12:44:42.853 回答
4
在 Adwords API 中,关键字被称为 AdGroup Criteria。您可以使用AdGroupCriterionService添加或检索特定 AdGroup 的关键字。
如果您使用 Adwords API 的 PHP 客户端库,请查看GetAllAdGroupCriteria.php
示例文件。(不要忘记首先输入要获取关键字的 AdGroupId)
于 2011-12-14T15:36:40.267 回答