Hi, If you pass a NULL for the filePath, the DownloadReport will return the report as a String.
Cheers, Anash P. Oommen, AdWords API Advisor. On Friday, January 23, 2015 at 1:20:19 AM UTC+5:30, Desenvolvimento - Grupo Lead Negócios Inteligentes wrote: > > Olá pessoal, é meu primeiro post aqui no fórum, por isso peço perdão por > qualquer erro. :D > > Galera, é o seguinte, estou começando agora a desvendar a API e estou com > uma dúvida: o script que colei abaixo, só faz o download da campanha em > questão, eu quero saber se consigo, ao invés de fazer o download, colocar > os dados em alguma variável, por exempo, colocar clicks em uma varialvel, > CTR em outra e assim por diante, tem como? Se sim, como? kkkk > > <?php > error_reporting(-1); > ini_set('display_errors',1); > $path = dirname(__FILE__) . '/../../src'; > set_include_path(get_include_path() . PATH_SEPARATOR . $path); > > require_once '/Google/Api/Ads/AdWords/Lib/AdWordsUser.php'; > > $user = new AdWordsUser(); > > $user->SetClientId('8214013316'); > > // Log SOAP XML request and response. > $user->LogDefaults(); > > $user->LoadService('ReportDefinitionService', 'v201409'); > $LoadService = $user->LoadService('ReportDefinitionService', 'v201409'); > > // Create selector. > $selector = new Selector(); > $selector->fields = array('CampaignId', 'AdGroupId', 'Id', 'Criteria', > 'CriteriaType', 'Impressions', 'Clicks', 'Conversions', 'Cost', > 'CustomerDescriptiveName', 'Ctr', 'AveragePosition'); > > // Filter out deleted criteria. > //$selector->predicates[] = new Predicate('Status', 'NOT_IN', > array('DELETED')); > > // Create report definition. > $reportDefinition = new ReportDefinition(); > $reportDefinition->selector = $selector; > $reportDefinition->reportName = 'Criteria performance report #' . uniqid(); > $reportDefinition->dateRangeType = 'ALL_TIME'; > $reportDefinition->reportType = 'CRITERIA_PERFORMANCE_REPORT'; > $reportDefinition->downloadFormat = 'XML'; //CSVFOREXCEL > > // Salva o arquivo no caminho indicado abaixo > $filePath = dirname(__FILE__) . '/report.xml'; > > // Exclude criteria that haven't recieved any impressions over the date > range. > $reportDefinition->includeZeroImpressions = FALSE; > > // Set additional options. > $options = array('version' => 'v201409', 'returnMoneyInMicros' => TRUE); > > // Download report. > ReportUtils::DownloadReport($reportDefinition, $filePath, $user, $options); > > > printf("Report with name '%s' was downloaded to '%s'.\n", > $reportDefinition->reportName, $filePath); > > > $doc = new DOMDocument(); > $doc->loadXML(file_get_contents($filePath)); > $xp = new DOMXPath($doc); > $q = $xp->query("/report/table/row/@cost"); > $cost = 0; > foreach($q as $el) { > $v = $el->textContent; > $cost += $v / 1000000; > } > > echo "Custo: ".$cost; > ?> > > Desde já, obrigado! > -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ 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. Visit this group at http://groups.google.com/group/adwords-api. To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/e2ca71e1-88c2-4b34-a1e1-d0ca045f0c7e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.