Hi,

  i'm using 'google-api-php-client' library and API VERSION '201309' to 
implement a web application which will help me manage my campaigns.

  So far everything is working as it should. I can connect to API and gain 
information regarding names of my Accounts, and their Campaigns or AdGroups.
 
  What i need next, is to get info regarding Clicks and/or Cost of a 
specified Campaign. And here is where the problem occurs....

  If the campaign which I try to get info for, has status='Paused', then i 
can get the right data. But if Campaign's status is 'Active', then all
  i get from API, is zero values.

  So, what I want to ask is, if I'm missing something here, or if someone 
else has encountered this problem before, and if so, how did he made to 
solve it.

  Below, I quote a section of the code which performs the call to the API, 
in order to get the Campaign's info.

  Any help will be greatly appreciated.

  Thanks in advance.


$campaignService = $user->GetService('CampaignService', $adwords_version);
$selector = new Selector();
$selector->fields = array('Id', 'Name', 'Status', 'StartDate', 'EndDate');
$selector->predicates[] = new Predicate('Id','IN', array($campaignId));

$selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
do {
$page = $campaignService->get($selector);
if (isset($page->entries)) {
         foreach ($page->entries as $campaign) {
  if ($campaign->status!='DELETED')
            {

  $user->LoadService('ReportDefinitionService', $adwords_version);
                $selector2 = new Selector();
                $selector2->fields = array('CampaignId','Clicks', 
'Cost','AverageCpc');
                $selector2->predicates[] = new Predicate('CampaignId','IN', 
array($campaign->id));

$reportDefinition = new ReportDefinition();
                $reportDefinition->selector = $selector2;
                $reportDefinition->reportName = 'Criteria performance 
report #' . uniqid();
                $reportDefinition->dateRangeType ='ALL_TIME';
                $reportDefinition->reportType = 
'CRITERIA_PERFORMANCE_REPORT';
                $reportDefinition->downloadFormat = 'CSV';
                $options = array('version' => $adwords_version, 
'returnMoneyInMicros' => FALSE);
                $filePathreport='./reports/campaignreport.txt';
                ReportUtils::DownloadReport($reportDefinition, 
$filePathreport, $user, $options);

$rows = file($filePathreport);
                
                $last_row = array_pop($rows);
                $LastLine = str_getcsv($last_row);
                
                $myclicks=$LastLine[1];
                $mycost=$LastLine[2];
                $myavcpc=$LastLine[3];
                
                unlink($filePathreport);

 ........................................................................
   
...................................................................................
     
..........................................................................................

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 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 Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to