使用Google AdWords API和PHP来获得关键词CPC和每月搜索量


Use Google AdWords API with PHP to get keyword CPC and monthly search volume

我想使用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