CLIENT_CUSTOMER_ID_INVALID exception when using AdWords API with PHP

717 views
Skip to first unread message

vahid seo

unread,
May 6, 2014, 12:41:50 PM5/6/14
to adwor...@googlegroups.com
I get an [AuthenticationError.CLIENT_CUSTOMER_ID_INVALID @ ; trigger:''] exception when I execute the code below. I just want to get some info about a word, in this case "books". What is wrong with the code? What's wrong with my Google AdWords account?

By the way, how many requests can I send per day? What do I have to do for unlimited requests? Should I pay some money? Please help me.

Thanks in advance.

<?php

$path = dirname( __FILE__ ) . PATH_SEPARATOR . "lib";
set_include_path(get_include_path() . PATH_SEPARATOR . $path);

require_once 'lib/Google/Api/Ads/AdWords/Lib/AdWordsUser.php';
require_once 'lib/Google/Api/Ads/Common/Util/MapUtils.php';


function getWord(AdWordsUser $user) {
  // Get the service, which loads the required classes.
  $targetingIdeaService = $user->GetTargetingIdeaService('v201402');

  // Create seed keyword.
  $keyword = 'Books';

  // Create selector.
  $selector = new TargetingIdeaSelector();
  $selector->requestType = 'IDEAS';
  //$selector->requestType = 'STATS';
  $selector->ideaType = 'KEYWORD';
  $selector->requestedAttributeTypes =
      array('AVERAGE_CPC', 'COMPETITION', 'SEARCH_VOLUME', 'TARGETED_MONTHLY_SEARCHES');

  // Create related to keyword search parameter.
  $selector->searchParameters[] =
      new RelatedToQuerySearchParameter(array($keyword));

  // 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)) {
 print_r ( $page->entries );
 
    } else {
      print "N/A";
    }

    // Advance the paging index.
    $selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
  } while ($page->totalNumEntries > $selector->paging->startIndex);
}


try {

$oauth2Info = array(
'client_id' => "my_client_id",
'client_secret' => "my_client_secret",
'refresh_token' => 'my_refresh_token'
);

  $user = new AdWordsUser(NULL, 'my_email', 'my_password', 'my_email++currency', 'my_token', 'user_agent', NULL, NULL, NULL, $oauth2Info);

  $user->SetClientId('xxx-xxx-xxxx');


  // Run the example.
  getWord($user);
} catch (Exception $e) {
  printf($e->getMessage());
}
?>

Ray Tsang (AdWords API Team)

unread,
May 6, 2014, 7:23:27 PM5/6/14
to adwor...@googlegroups.com
Vahid,

You should set the client customer ID - with $user->SetClientCustomerId(....).

Thanks,

Ray

vahid seo

unread,
May 7, 2014, 2:25:02 AM5/7/14
to adwor...@googlegroups.com
Thank you very much, Ray. Man, I can't thank you enough.

Vahid

Ray Tsang (AdWords API Team)

unread,
May 7, 2014, 2:42:54 PM5/7/14
to adwor...@googlegroups.com
You are welcome!

Cheers,

Ray
Reply all
Reply to author
Forward
0 new messages