结合使用Google AdWords API和PHP来获取关键字每次点击费用和每月搜索量 [英] Use Google AdWords API with PHP to get keyword CPC and monthly search volume

查看:171
本文介绍了结合使用Google AdWords API和PHP来获取关键字每次点击费用和每月搜索量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 Google AdWords API 来获取每月搜索量 CPC ,其中某些关键字 PHP . API本身使我感到困惑,阅读文档,论坛主题以及问题和答案的次数越多,我就越困惑.

I want to use Google AdWords API to get monthly search volume and CPC for some keywords with PHP. The API itself made me so confused, and the more I read documentations and forum threads and questions and answers, the more confused I got.

谁能以一种非常简单的方式向我解释它的工作原理,并告诉我如何逐步构建并运行它吗??

Can anyone please explain how it works to me in a really really simple way, and tell me how to make it up and running step by step?

谢谢.

推荐答案

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

Yes, here is an example file to get a list of keywords and volume.

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的示例输出.

Here is sample output using the TrafficEstimatorService, not the similar TargetingIdeaService above.

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

这篇关于结合使用Google AdWords API和PHP来获取关键字每次点击费用和每月搜索量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆