Newb: No campaigns were found.

67 views
Skip to first unread message

Joe M

unread,
Jun 23, 2016, 12:09:38 PM6/23/16
to AdWords API Forum
Hello 

All of my credentials i.e. developer token, user agent, client customer id, (oauth2) client id, client secret, refresh token have been added to the auth.ini file. 

; Detailed descriptions of these properties can be found at:
; https://developers.google.com/adwords/api/docs/headers

developerToken = "my developer token"
userAgent = "my user agent"

; Uncomment clientCustomerId to make requests against a single AdWords account,
; such as when you run the examples.
; If you don't set it here, you can set the client customer ID dynamically:
; $user = new AdWordsUser();
; $user->SetClientCustomerId(...);

clientCustomerId = "my client customer id 10 digit"

[OAUTH2]

; If you do not have a client ID or secret, please create one of type
; "installed application" in the Google API console:
; https://cloud.google.com/console
client_id = "my oauth2 generated client id"
client_secret = "my oauth2 generated client secret"

; If you already have a refresh token, enter it below. Otherwise run
; GetRefreshToken.php.
refresh_token = "my generated token"

; Optionally, uncomment the oAuth2AdditionalScopes line to provide additional
; OAuth2 scopes. The AdWords API OAuth2 scope is always included. For
; additional OAuth2 scopes, reference the OAuth 2.0 Playground
; (https://developers.google.com/oauthplayground/). In the playground, each
; application has a list of OAuth2 scopes. For example, you would enter
; https://www.googleapis.com/auth/analytics here as a value if you would like
; to include Google Analytics as an additional scope.
; oAuth2AdditionalScopes = "INSERT_COMMA_SEPARATED_LIST_OF_SCOPES_HERE"

I am running this script:

$this->user = new AdWordsUser();
$campaignService = $this->user->GetService('CampaignService', $this->adwordsVersion);
// Create AWQL query.
$query = 'SELECT Id, Name, Status ORDER BY Name';

// Create paging controls.
$offset = 0;

do {
$pageQuery = sprintf('%s LIMIT %d,%d', $query, $offset,
AdWordsConstants::RECOMMENDED_PAGE_SIZE);
// Make the query request.
$page = $campaignService->query($pageQuery);

// Display results.
if (isset($page->entries)) {
foreach ($page->entries as $campaign) {
printf("Campaign with name '%s' and ID '%s' was found.\n",
$campaign->name, $campaign->id);
}
} else {
var_dump($page);
echo "No campaigns were found.\n";
}

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

However, No campaigns were found yet I do have campaigns. I am not running this with Test accounts. The credentials are for the Production account. I am using the MCC Client ID. I have research this everywhere with no resolution.  Please help as to what I am doing wrong.  If you need more info please let me know. 

Thanks!
Joe












Vishal Vinayak (Adwords API Team)

unread,
Jun 23, 2016, 2:59:43 PM6/23/16
to AdWords API Forum
Hi Joe, 

Have you tried using the AdWords account ID instead of the MCC account ID? If yes then provide me privately SOAP XML request and response logs. Please click on Reply privately to author when responding.

Regards,
Vishal, Adwords API Team
Reply all
Reply to author
Forward
0 new messages