hello i have a php code that i have edit from semples
i need to get all the Extensions from adgroup level , list them and retrive
their data
on CallFeedItem i need to get :callPhoneNumber
on SitelinkFeedItem i need to get sitelinkText , sitelinkUrl
on CalloutFeedItem i need to get calloutText
use Google\AdsApi\AdWords\AdWordsServices;
use Google\AdsApi\AdWords\AdWordsSession;
use Google\AdsApi\AdWords\AdWordsSessionBuilder;
use Google\AdsApi\AdWords\v201702\cm\AdGroupExtensionSettingService;
use Google\AdsApi\Common\OAuth2TokenBuilder;
class GetCampaignsWithAwql {
const PAGE_LIMIT = 100;
public static function runExample(AdWordsServices $adWordsServices,
AdWordsSession $session) {
$campaignService = $adWordsServices->get($session,
AdGroupExtensionSettingService ::class);
$qury = $_GET["adgroup"];
// Create AWQL query.
$query = "SELECT AdGroupId, ExtensionType , Extensions WHERE AdGroupId
= '".$qury."' ";
// Create paging controls.
$totalNumEntries = 0;
$adgroups = array();
$offset = 0;
do {
$pageQuery = sprintf('%s LIMIT %d,%d', $query, $offset,
self::PAGE_LIMIT);
$page = $campaignService->query($pageQuery);
// Display results from the query.
if ($page->getEntries() !== null) {
$totalNumEntries = $page->getTotalNumEntries();
foreach ($page->getEntries() as $extension) {
$arr = array(
"adgroup_id" => $extension->getAdGroupId() ,
"extensions" => $extension->getExtensionSetting()->getExtensions(),
//"sitelinkUrl" => $extension->getSitelinkUrl() ,
"type" => $extension->getExtensionType()
);
array_push($adgroups,$arr );
}
}
// Advance the paging offset.
$offset += self::PAGE_LIMIT;
} while ($offset < $totalNumEntries);
$array_data = json_encode($adgroups,true);
exit($array_data);
}
public static function main() {
// Generate a refreshable OAuth2 credential for authentication.
$oAuth2Credential = (new OAuth2TokenBuilder())
->fromFile()
->build();
// Construct an API session configured from a properties file and the
OAuth2
// credentials above.
$session = (new AdWordsSessionBuilder())
->fromFile()
->withOAuth2Credential($oAuth2Credential)
->build();
self::runExample(new AdWordsServices(), $session);
}
}
GetCampaignsWithAwql::main();
this is what i get now in json
[{"adgroup_id":1900848642,"extensions":[{"ExtensionFeedItem.Type":"SitelinkFeedItem"},{"ExtensionFeedItem.Type":"SitelinkFeedItem"},{"ExtensionFeedItem.Type":"SitelinkFeedItem"},{"ExtensionFeedItem.Type":"SitelinkFeedItem"}],"type":"SITELINK"},{"adgroup_id":1900848642,"extensions":[{"ExtensionFeedItem.Type":"CallFeedItem"}],"type":"CALL"}]
thanks
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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/f5e9a3ac-6039-4290-bdb9-b0af7a319ee3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.