You don't understand me.

Just copy and paster this code to your file and run it. Without any
chagnes, edits.
After you will get it to work - you can do it what ever you want.

<?php
require_once 'aw-api/src/Google/Api/Ads/AdWords/Lib/AdWordsUser.php';
require_once 'aw-api/src/Google/Api/Ads/Common/Util/MapUtils.php';
require_once 'aw-api/src/Google/Api/Ads/AdWords/v201109/
TargetingIdeaService.php';

try {
  // Get AdWordsUser from credentials in "../auth.ini"
  // relative to the AdWordsUser.php file's directory.
  $user = new AdWordsUser();

  // Log SOAP XML request and response.
  $user->LogDefaults();

  // Get the TargetingIdeaService.
  $targetingIdeaService = $user->GetService('TargetingIdeaService',
'v201109');

  // Create seed keyword.
  $keyword = new Keyword();
  $keyword->text = 'mars cruise';
  $keyword->matchType = 'BROAD';

  // Create selector.
  $selector = new TargetingIdeaSelector();
  $selector->requestType = 'IDEAS';
  $selector->ideaType = 'KEYWORD';
  $selector->requestedAttributeTypes =
      array('CRITERION', 'AVERAGE_TARGETED_MONTHLY_SEARCHES');

  // Set selector paging (required for targeting idea service).
  $paging = new Paging();
  $paging->startIndex = 0;
  $paging->numberResults = 10;
  $selector->paging = $paging;

  // Create related to keyword search parameter.
  $relatedToKeywordSearchParameter = new
RelatedToKeywordSearchParameter();
  $relatedToKeywordSearchParameter->keywords = array($keyword);

  // Create keyword match type search parameter to ensure unique
results.
  $keywordMatchTypeSearchParameter = new
KeywordMatchTypeSearchParameter();
  $keywordMatchTypeSearchParameter->keywordMatchTypes =
array('BROAD');

  // Start changes
  $locations = array();
  $location = new Location();
  $location->id = 2840; // Id can be found with examples/v201109/
GetLocationCriteria.php
                                  // I've selected whole United States
  $locations[] = $location;

  $locationTargetParameter = new
LocationSearchParameter($locations); // Expects arra of locations

  $selector->searchParameters =
      array($relatedToKeywordSearchParameter,
$keywordMatchTypeSearchParameter, $locationTargetParameter);
  // End changes

  // Get related keywords.
  $page = $targetingIdeaService->get($selector);

  // Display related keywords.
  if (isset($page->entries)) {
    foreach ($page->entries as $targetingIdea) {
      $data = MapUtils::GetMap($targetingIdea->data);
      $keyword = $data['CRITERION']->value;
      $averageMonthlySearches =
          isset($data['AVERAGE_TARGETED_MONTHLY_SEARCHES']->value)
          ? $data['AVERAGE_TARGETED_MONTHLY_SEARCHES']->value : 0;
      printf("Keyword with text '%s', match type '%s', and average
monthly "
          . "search volume '%s' was found.\n", $keyword->text,
          $keyword->matchType, $averageMonthlySearches);
    }
  } else {
    print "No related keywords were found.\n";
  }
} catch (Exception $e) {

  print $e->getMessage();
}

?>

On 1 янв, 00:01, jepster <400...@googlemail.com> wrote:
> Thank's for your answer.. but I'm sorry - it isn't still working.
>
> I've added your code after
>
> try {
>
> before
>
> // START CHANGES
>
> like you wrote.
>
> <?php
> require_once 'aw-api/src/Google/Api/Ads/AdWords/Lib/AdWordsUser.php';
> require_once 'aw-api/src/Google/Api/Ads/Common/Util/MapUtils.php';
> require_once 'aw-api/src/Google/Api/Ads/AdWords/v201109/
> TargetingIdeaService.php';
>
> try {
>     // Create selector. Important! What data you want to load?
>     $selector = new TargetingIdeaSelector();
>     $selector->requestType = 'IDEAS';
>     $selector->ideaType = 'KEYWORD';
>     $selector->requestedAttributeTypes =
>         array('CRITERION', 'AVERAGE_TARGETED_MONTHLY_SEARCHES');
>     /* Set selector paging (required for targeting idea service).
> Important (how many keywords you want to load) */
>     $paging = new Paging();
>     $paging->startIndex = 0;
>     $paging->numberResults = 10;
>     $selector->paging = $paging;
>     /* Create related to keyword search parameter.  (Important - you
>   need to specify, what type of data you want to get - about keyword
> or
>       about URL)
>     */
>     $relatedToKeywordSearchParameter = new
>     RelatedToKeywordSearchParameter();
>     $relatedToKeywordSearchParameter->keywords = array($keyword);
>
>   // START CHANGES
>
>   $locations = array();
>   $location = new Location();
>   $location->id = 2840; //Id can be found with examples/v201109/
> GetLocationCriteria.php
>
>   $locations[] = $location;
>   $locationTargetParameter = new
> LocationSearchParameter($locations); // Expects arra of locations
>   $selector->searchParameters =
>   array($relatedToKeywordSearchParameter,
>   $keywordMatchTypeSearchParameter, $locationTargetParameter);
>
>   // END CHANGES
>
>   // Get related keywords.
>   $page = $targetingIdeaService->get($selector);
>
>   // Display related keywords.
>   if (isset($page->entries)) {
>     foreach ($page->entries as $targetingIdea) {
>       $data = MapUtils::GetMap($targetingIdea->data);
>       $keyword = $data['CRITERION']->value;
>       $averageMonthlySearches =
>           isset($data['AVERAGE_TARGETED_MONTHLY_SEARCHES']->value)
>           ? $data['AVERAGE_TARGETED_MONTHLY_SEARCHES']->value : 0;
>       printf("Keyword with text '%s', match type '%s', and average
> monthly "
>           . "search volume '%s' was found.\n", $keyword->text,
>           $keyword->matchType, $averageMonthlySearches);
>     }
>   } else {
>     print "No related keywords were found.\n";
>   }} catch (Exception $e) {
>
>   print $e->getMessage();}
>
> ?>
>
> On 30 Dez., 08:47, Evgeniy Bogdanov <bogda...@tagan.ru> wrote:
>
>
>
>
>
>
>
> > As I see you've deleted some important parts of code:
>
> >   // Create selector. Important! What data you want to load?
> >   $selector = new TargetingIdeaSelector();
> >   $selector->requestType = 'IDEAS';
> >   $selector->ideaType = 'KEYWORD';
> >   $selector->requestedAttributeTypes =
> >       array('CRITERION', 'AVERAGE_TARGETED_MONTHLY_SEARCHES');
> >   // Set selector paging (required for targeting idea service). //
> > Important (how many keywords you want to load)
> >   $paging = new Paging();
> >   $paging->startIndex = 0;
> >   $paging->numberResults = 10;
> >   $selector->paging = $paging;
> >   // Create related to keyword search parameter.  (Important - you
> > need to specify, what type of data you want to get - about keyword or
> > about URL)
> >   $relatedToKeywordSearchParameter = new
> > RelatedToKeywordSearchParameter();
> >   $relatedToKeywordSearchParameter->keywords = array($keyword);
>
> > Insert this code before // START CHANGES and it should work.
>
> > If you want to download data about 1 keyword, and do not want get
> > related keywords for your seed keyword - you need to change:
> >  $selector->requestType = 'IDEAS';
> > to
> >  $selector->requestType = 'STATS';
>
> > But loading data for 1 keyword is not economically effective as you
> > will be charged 6 API units for this action. (5 per call
> > TargetingIdeaService + 0.1 rounded to 1).
> > For example loading data for 10 keywords, you will be charged for 6
> > API units too.
>
> > In that case you better to review your requirements and create more
> > effective code.
>
> > Regards,
> > Evgeniy.
>
> > On 30 дек, 03:25, jepster <400...@googlemail.com> wrote:
>
> > > Thank's for your answer, but I still cannot solve it.
>
> > > The following is my whole code, which I get the error message
> > > "Unmarshalling Error: cvc-type.2: The type definition cannot be
> > > abstract for element ns1:searchParameters."
>
> > > <?php
> > > // require_once 'aw-api/src/Google/Api/Ads/AdWords/Lib/
> > > AdWordsUser.php';
>
> > > /**
> > >  * This example gets keywords related to a seed keyword.
> > >  *
> > >  * Tags: TargetingIdeaService.get
> > >  * Restriction: adwords-only
> > >  *
> > >  * PHP version 5
> > >  *
> > >  * Copyright 2011, Google Inc. All Rights Reserved.
> > >  *
> > >  * Licensed under the Apache License, Version 2.0 (the "License");
> > >  * you may not use this file except in compliance with the License.
> > >  * You may obtain a copy of the License at
> > >  *
> > >  *    http://www.apache.org/licenses/LICENSE-2.0
> > >  *
> > >  * Unless required by applicable law or agreed to in writing, software
> > >  * distributed under the License is distributed on an "AS IS" BASIS,
> > >  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> > > implied.
> > >  * See the License for the specific language governing permissions and
> > >  * limitations under the License.
> > >  *
> > >  * @package    GoogleApiAdsAdWords
> > >  * @subpackage v201109
> > >  * @category   WebServices
> > >  * @copyright  2011, Google Inc. All Rights Reserved.
> > >  * @license    http://www.apache.org/licenses/LICENSE-2.0Apache
> > > License,
> > >  *             Version 2.0
> > >  * @author     Eric Koleda <api.ekol...@gmail.com>
> > >  */
>
> > > error_reporting(E_ALL);
>
> > > // You can set the include path to src directory or reference
> > > // AdWordsUser.php directly via require_once.
> > > // $path = '/path/to/aw_api_php_lib/src';
> > > $path = dirname(__FILE__) . '/../../src';
> > > set_include_path(get_include_path() . PATH_SEPARATOR . $path);
>
> > > require_once 'aw-api/src/Google/Api/Ads/AdWords/Lib/AdWordsUser.php';
> > > require_once 'aw-api/src/Google/Api/Ads/Common/Util/MapUtils.php';
>
> > > try {
> > >   // Get AdWordsUser from credentials in "../auth.ini"
> > >   // relative to the AdWordsUser.php file's directory.
> > >   $user = new AdWordsUser();
>
> > >   // Log SOAP XML request and response.
> > >   $user->LogDefaults();
>
> > >   // Get the TargetingIdeaService.
> > >   $targetingIdeaService = $user->GetService('TargetingIdeaService',
> > > 'v201109');
>
> > >   // Create seed keyword.
> > >   $keyword = new Keyword();
> > >   $keyword->text = 'mars cruise';
> > >   $keyword->matchType = 'BROAD';
>
> > >   // START CHANGES
>
> > >   $locations = array();
> > >   $location = new Location();
> > >   $location->id = 2840; //Id can be found with examples/v201109/
> > > GetLocationCriteria.php
>
> > >   $locations[] = $location;
> > >   $locationTargetParameter = new
> > > LocationSearchParameter($locations); // Expects arra of locations
> > >   $selector->searchParameters =
> > >   array($relatedToKeywordSearchParameter,
> > >   $keywordMatchTypeSearchParameter, $locationTargetParameter);
>
> > >   // END CHANGES
>
> > >   // Get related keywords.
> > >   $page = $targetingIdeaService->get($selector);
>
> > >   // Display related keywords.
> > >   if (isset($page->entries)) {
> > >     foreach ($page->entries as $targetingIdea) {
> > >       $data = MapUtils::GetMap($targetingIdea->data);
> > >       $keyword = $data['CRITERION']->value;
> > >       $averageMonthlySearches =
> > >           isset($data['AVERAGE_TARGETED_MONTHLY_SEARCHES']->value)
> > >           ? $data['AVERAGE_TARGETED_MONTHLY_SEARCHES']->value : 0;
> > >       printf("Keyword with text '%s', match type '%s', and average
> > > monthly "
> > >           . "search volume '%s' was found.\n", $keyword->text,
> > >           $keyword->matchType, $averageMonthlySearches);
> > >     }
> > >   } else {
> > >     print "No related keywords were found.\n";
> > >   }} catch (Exception $e) {
>
> > >   print $e->getMessage();}
>
> > > ?>
>
> > > On 29 Dez., 19:29, Evgeniy Bogdanov <bogda...@tagan.ru> wrote:
>
> > > > My code were outdated. For not last version of API (which is currently
> > > > v201109).
> > > > I've researched this issue and this is new version of code that you
> > > > need, it's based on examples/v201109/GetRelatedKeywords.php, changes
> > > > are commented:
>
> > > > try {
> > > >   // Get AdWordsUser from credentials in "../auth.ini"
> > > >   // relative to the AdWordsUser.php file's directory.
> > > >   $user = new AdWordsUser();
>
> > > >   // Log SOAP XML request and response.
> > > >   $user->LogDefaults();
>
> > > >   // Get the TargetingIdeaService.
> > > >   $targetingIdeaService = $user->GetService('TargetingIdeaService',
> > > > 'v201109');
>
> > > >   // Create seed keyword.
> > > >   $keyword = new Keyword();
> > > >   $keyword->text = 'mars cruise';
> > > >   $keyword->matchType = 'BROAD';
>
> > > >   // Create selector.
> > > >   $selector = new TargetingIdeaSelector();
> > > >   $selector->requestType = 'IDEAS';
> > > >   $selector->ideaType = 'KEYWORD';
> > > >   $selector->requestedAttributeTypes =
> > > >       array('CRITERION', 'AVERAGE_TARGETED_MONTHLY_SEARCHES');
>
> > > >   // Set selector paging (required for targeting idea service).
> > > >   $paging = new Paging();
> > > >   $paging->startIndex = 0;
> > > >   $paging->numberResults = 10;
> > > >   $selector->paging = $paging;
>
> > > >   // Create related to keyword search parameter.
> > > >   $relatedToKeywordSearchParameter = new
> > > > RelatedToKeywordSearchParameter();
> > > >   $relatedToKeywordSearchParameter->keywords = array($keyword);
>
> > > >   // Create
>
> ...
>
> продолжение >>

-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
http://adwordsapi.blogspot.com
http://groups.google.com/group/adwords-api
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en

Reply via email to