【问题标题】:Use Google AdWords API with PHP to get keyword CPC and monthly search volume使用带有 PHP 的 Google AdWords API 获取关键字 CPC 和每月搜索量
【发布时间】:2014-06-18 22:14:44
【问题描述】:

我想使用 Google AdWords API 来获得 每月搜索量CPC 一些关键字 与 PHP。 API 本身让我很困惑,我越是阅读文档和论坛主题以及问题和答案,我就越感到困惑。

谁能以一种非常简单的方式向我解释它是如何工作的,并告诉我如何一步一步地完成它并运行它

提前致谢。

【问题讨论】:

    标签: php api keyword google-ads-api keyword-search


    【解决方案1】:

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

    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
    

    【讨论】:

      猜你喜欢
      • 2011-06-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多