gpt4 book ai didi

google-ads-api - google adwords api + 获取所有关键字

转载 作者:行者123 更新时间:2023-12-04 19:50:53 27 4
gpt4 key购买 nike

我正在使用 google adwords api,我可以检索所有广告系列、组广告、广告,
但我不知道如何检索与“组广告”相关的关键字。
在 google adwords 界面中,当我们选择一组广告时,我们有两个标签,一个是与该组广告相关的广告,第二个是关键字。
但以编程方式,现在我只能检索广告。
我正在使用 PHP,如果有人知道如何用 php 或其他编程语言甚至肥皂调用来做到这一点。

最佳答案

要获取广告组所有关键字的详细信息,您需要以下内容来获取所有关键字的详细信息。

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());
}

关于google-ads-api - google adwords api + 获取所有关键字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4008144/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com