Cant get campaigns list

35 views
Skip to first unread message

Denis Kolomensky

unread,
Oct 4, 2020, 1:40:09 PM10/4/20
to AdWords API and Google Ads API Forum
I created a google oauth2 client. I got a refresh token at https://developers.google.com/oauthplayground
Then I created an adwords account and got api dev token. 
I created few campaigns. I'm trying to get campaign list but api call always return 0.
See code bellow:

Denis Kolomensky

unread,
Oct 4, 2020, 1:55:53 PM10/4/20
to AdWords API and Google Ads API Forum
$oAuth2Credential = (new OAuth2TokenBuilder())
->withClientId(env('GOOGLE_CLIENT_ID'))
->withClientSecret(env('GOOGLE_CLIENT_SECRET'))
->withRefreshToken(env('AD_WORDS_REFRESH_TOKEN'))
->build();
$session = (new AdWordsSessionBuilder())
->withOAuth2Credential($oAuth2Credential)
->withDeveloperToken(env('AD_WORDS_DEV_TOKEN'))
->withClientCustomerId(env('CLIENT_CUSTOMER_ID'))
->build();
$adWordsServices = new AdWordsServices();
$campaignService = $adWordsServices->get($session, CampaignService::class);
// Create selector.
$selector = new Selector();
$selector->setFields(['Id', 'Name']);
$selector->setOrdering([new OrderBy('Name', SortOrder::ASCENDING)]);
$selector->setPaging(new Paging(0, 500));
$totalNumEntries = 0;
do {
// Make the get request.
$page = $campaignService->get($selector);

// Display results.
if ($page->getEntries() !== null) {
$totalNumEntries = $page->getTotalNumEntries();
foreach ($page->getEntries() as $campaign) {
printf(
"Campaign with ID %d and name '%s' was found.\n",
$campaign->getId(),
$campaign->getName()
);
}
}
// Advance the paging index.
$selector->getPaging()->setStartIndex(
$selector->getPaging()->getStartIndex() + 500
);
} while ($selector->getPaging()->getStartIndex() < $totalNumEntries);

printf("Number of results found: %d\n", $totalNumEntries);

воскресенье, 4 октября 2020 г. в 20:40:09 UTC+3, Denis Kolomensky:

Google Ads API Forum Advisor Prod

unread,
Oct 4, 2020, 9:29:27 PM10/4/20
to wepro...@gmail.com, adwor...@googlegroups.com
Hi Denis,

Thanks for posting your concern.

To investigate the issue, could you provide the complete SOAP request and response logs generated on your end together with the customer ID? You can provide the requested details via Reply privately to author option.

Regards,
Google Logo
Ernie John Blanca Tacata
Google Ads API Team
 


ref:_00D1U1174p._5004Q25Z4hJ:ref
Reply all
Reply to author
Forward
0 new messages