I tried post this an hour ago, but it seems as though I must have discarded 
it. I'm trying to get a list of ad groups, and it works on my test account, 
but doesn't work on my real account.

On my test account:
[2017-05-12 18:15:11] AW_SOAP.INFO: clientCustomerId= operations=1 
service=AdGroupService method=query responseTime=450 
requestId=server=adwords.google.com isFault=0 faultMessage=
Found ad group ID #1234567890



On my real account:
[2017-05-12 18:32:32] AW_SOAP.INFO: clientCustomerId= operations=1 
service=AdGroupService method=query responseTime=205 requestId= 
server=adwords.google.com isFault=0 faultMessage=
No entries found for ads groups. \app\Console\Commands\AdwordsSync.php:57

The modified sample code.
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Config;

use Google\AdsApi\AdWords\AdWordsServices;
use Google\AdsApi\AdWords\AdWordsSession;
use Google\AdsApi\AdWords\AdWordsSessionBuilder;
use Google\AdsApi\AdWords\v201702\cm\CampaignService;
use Google\AdsApi\AdWords\v201702\cm\AdGroupService;
use Google\AdsApi\AdWords\v201702\cm\AdGroupAdService;
use Google\AdsApi\Common\OAuth2TokenBuilder;
class AdwordsSync extends Command {
    protected $signature = 'Adwords:Sync';
    protected $description = 'Synchronize adwords campaign data';
    protected $session = null;

    public function __construct()
    {
        parent::__construct();
    }
    const PAGE_LIMIT = 500;
    
    public function handle() {
        $oAuth2Credential = (new OAuth2TokenBuilder())
            ->fromFile()
            ->build();

        // Construct an API session configured from a properties file and 
the OAuth2
        // credentials above.
        $this->session = (new AdWordsSessionBuilder())
            ->fromFile()
            ->withOAuth2Credential($oAuth2Credential)
            ->build();

        $this->adWordsServices = new AdWordsServices();
        $this->adGroupService = $this->adWordsServices->get($this->session, 
AdGroupService::class);

        $offset = 0;

        $query = 'SELECT Id, Name, Status, CampaignId ORDER BY Id';

            $pageQuery = sprintf('%s LIMIT %d,%d', $query, $offset, 
self::PAGE_LIMIT);
            // Make the query request.
            $page = $this->adGroupService->query($pageQuery);

            // Display results from the query.
            if ($page->getEntries() !== null) {
                foreach ($page->getEntries() as $adGroup) {
                    $id = $adGroup->getId();
                    printf("Found ad group ID #%s",$id);
                }
            } else {
                echo "No entries found for ads groups. ".__FILE__. ":" . 
__LINE__ . "\n";
            }
    }
}






-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/37558699-f5eb-47a3-be1f-9e42992ab562%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • AdGroupService ... Steven Horton
    • Re: AdGrou... 'Shwetha Vastrad (AdWords API Team)' via AdWords API Forum
      • Re: Ad... Steven Horton
        • Re... 'Shwetha Vastrad (AdWords API Team)' via AdWords API Forum

Reply via email to