I am trying to get the CPC,cost,CTR ,impressions using GetTextAds ,but it's only giving like adtext ,headline and urls but not the others
function GetTextAdsExample(AdWordsUser $user, $adGroupId) {
// Get the service, which loads the required classes.
$adGroupAdService = $user->GetService('AdGroupAdService', ADWORDS_VERSION);
// Create selector.
$selector = new Selector();
$selector->fields = array('Headline', 'Id');
$selector->ordering[] = new OrderBy('Headline', 'ASCENDING');
// Create predicates.
$selector->predicates[] = new Predicate('AdGroupId', 'IN', array($adGroupId));
$selector->predicates[] = new Predicate('AdType', 'IN', array('TEXT_AD'));
// By default disabled ads aren't returned by the selector. To return them
// include the DISABLED status in a predicate.
$selector->predicates[] =
new Predicate('Status', 'IN', array('ENABLED', 'PAUSED', 'DISABLED'));
// Create paging controls.
$selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
do {
// Make the get request.
$page = $adGroupAdService->get($selector);
// Display results.
if (isset($page->entries)) {
foreach ($page->entries as $adGroupAd) {
global $retval;
$head=$adGroupAd->ad->headline;
$adid=$adGroupAd->ad->id;
$des1=$adGroupAd->ad->description1;
$des2=$adGroupAd->ad->description2;
$url=$adGroupAd->ad->displayUrl;
$clicks=$adGroupAd->stats->clicks;
$cpc=$adGroupAd->stats->averageCpc->microAmount / 1000000;
$conversions=$adGroupAd->stats->conversions;
$cost=$adGroupAd->stats->cost->microAmount / 1000000;
$ctr=$adGroupAd->stats->ctr;
$imp=$adGroupAd->stats->impressions;
$ap=$adGroupAd->stats->averagePosition;
//printf("Text ad with headline '%s' and ID '%s' was found.\n",
//$adGroupAd->ad->headline, $adGroupAd->ad->id);
array_push($retval,array("hea"=>$head,"id"=>$adid ,"desc"=>$des1 ,"desc2"=>$des2,"url"=>$url,
"cli"=>$clicks,"cpc"=>$cpc,"con"=>$conversions,"cost"=>$cost,"ctr"=>$ctr,"imp"=>$imp,"ap"=>$ap
));
}
echo json_encode($retval);
} else {
//print "No text ads were found.\n";
}
// Advance the paging index.
$selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
} while ($page->totalNumEntries > $selector->paging->startIndex);
}
try {
// Get AdWordsUser from credentials in "../auth.ini"
// relative to the AdWordsUser.php file's directory.
$user = new AdWordsUser();
// Log every SOAP XML request and response.
$user->LogAll();
// Run the example.
GetTextAdsExample($user, $adGroupId);
} catch (Exception $e) {
printf("An error has occurred: %s\n", $e->getMessage());
}