I'm not returning any results/entries when I try to query my adgroups on my 
account. On my real account, nothing happens, but on my test account, it 
works. My developer token has basic level access.

When I run the script with my test account, I get this result:
[2017-05-12 18:15:11] AW_SOAP.INFO: clientCustomerId=123-456-7890 
operations=1 service=AdGroupService method=query responseTime=450 
requestId=00000000000000000000000000000000 server=adwords.google.com 
isFault=0 faultMessage=
Found ad group ID #1234567890



When I run the script with my real account, I get this.
[2017-05-12 18:18:08] AW_SOAP.INFO: clientCustomerId=098-765-4321 
operations=1 service=AdGroupService method=query responseTime=178 
requestId=00000000000000000000000000000002 server=adwords.google.com 
isFault=0 faultMessage=  
No entries found for ads groups. 
C:\xampp\htdocs\app\Console\Commands\AdwordsSync.php:57

Here is the code, with some junk removed.

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Config;
// The machine

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";
            }
    }
}


In case you need this, my ini file isn't very descriptive.
[ADWORDS]
developerToken = "1234567890abcdefghijkl"
clientCustomerId = "123-456-7890"
[ADWORDS_REPORTING]
[OAUTH2]
clientId = 
"123456789012-abcdefghijklmnopqrstuvwxyz123456.apps.googleusercontent.com"
clientSecret = "abcdefghijklmnopqrstuvwx"
refreshToken = "a/bcdefghijklmnopqrstuvwxyz1234567890abcdefgh"
[SOAP]
[PROXY]
[LOGGING]


-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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/d0fd91a9-34d0-446f-ae2e-57cb67d3a010%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to