$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: 

> 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:
>
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
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 and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/b7a590be-b158-4023-8470-001e4a90bb63n%40googlegroups.com.

Reply via email to