gpt4 book ai didi

php - 使用带有 PHP 的 Google AdWords API 获取关键字每次点击费用和每月搜索量

转载 作者:行者123 更新时间:2023-12-05 07:58:49 25 4
gpt4 key购买 nike

我想使用 Google AdWords API 获取某些关键字每月搜索量CPC <强>PHP 。 API 本身让我很困惑,而且我阅读文档和论坛主题以及问题和答案越多,我就越困惑。

任何人都可以用一种非常非常简单的方式向我解释它是如何工作的,并告诉我如何逐步让它运行起来吗?

提前致谢。

最佳答案

是的,这是一个示例文件,用于获取关键字和数量列表。

https://github.com/googleads/googleads-php-lib/blob/master/examples/AdWords/v201502/Optimization/GetKeywordIdeas.php

function GetKeywordIdeasExample(AdWordsUser $user) {
// Get the service, which loads the required classes.
$targetingIdeaService =
$user->GetService('TargetingIdeaService', ADWORDS_VERSION);
// Create seed keyword.
$keyword = 'mars cruise';
// Create selector.
$selector = new TargetingIdeaSelector();
$selector->requestType = 'IDEAS';
$selector->ideaType = 'KEYWORD';
$selector->requestedAttributeTypes = array('KEYWORD_TEXT', 'SEARCH_VOLUME',
'CATEGORY_PRODUCTS_AND_SERVICES');
// Create language search parameter (optional).
// The ID can be found in the documentation:
// https://developers.google.com/adwords/api/docs/appendix/languagecodes
// Note: As of v201302, only a single language parameter is allowed.
$languageParameter = new LanguageSearchParameter();
$english = new Language();
$english->id = 1000;
$languageParameter->languages = array($english);
// Create related to query search parameter.
$relatedToQuerySearchParameter = new RelatedToQuerySearchParameter();
$relatedToQuerySearchParameter->queries = array($keyword);
$selector->searchParameters[] = $relatedToQuerySearchParameter;
$selector->searchParameters[] = $languageParameter;
// Set selector paging (required by this service).
$selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
do {
// Make the get request.
$page = $targetingIdeaService->get($selector);
// Display results.
if (isset($page->entries)) {
foreach ($page->entries as $targetingIdea) {
$data = MapUtils::GetMap($targetingIdea->data);
$keyword = $data['KEYWORD_TEXT']->value;
$search_volume = isset($data['SEARCH_VOLUME']->value)
? $data['SEARCH_VOLUME']->value : 0;
$categoryIds =
implode(', ', $data['CATEGORY_PRODUCTS_AND_SERVICES']->value);
printf("Keyword idea with text '%s', category IDs (%s) and average "
. "monthly search volume '%s' was found.\n",
$keyword, $categoryIds, $search_volume);
}
} else {
print "No keywords ideas were found.\n";
}
// Advance the paging index.
$selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
} while ($page->totalNumEntries > $selector->paging->startIndex);
}

这里是使用 TrafficEstimatorService 的示例输出,而不是上面类似的 TargetingIdeaService。

Keyword: cooling capacity window, match: EXACT, cpc: $0.00, vol: 0
Keyword: capacity window air, match: EXACT, cpc: $0.00, vol: 0
Keyword: oral-b professional deep sweep 4000 electric rechargeable toothbrush, match: EXACT, cpc: $0.00, vol: 0
Keyword: oral, match: EXACT, cpc: $0.00, vol: 347
Keyword: professional, match: EXACT, cpc: $0.00, vol: 721
Keyword: sweep, match: EXACT, cpc: $0.00, vol: 101
Keyword: toothbrush, match: EXACT, cpc: $0.16, vol: 17746
Keyword: oral b, match: EXACT, cpc: $0.26, vol: 17768
Keyword: b professional, match: EXACT, cpc: $0.00, vol: 0

关于php - 使用带有 PHP 的 Google AdWords API 获取关键字每次点击费用和每月搜索量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23424564/

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