Re: Creating keyword performace report usind adwords API

2012-03-22 Thread David Torres
Hi,

Aside from the great response from Ewan, I got to add that API reports were 
never intended to appear in the UI, so what you describe is not longer 
possible via the API.

Best,

-David Torres - AdWords API Team

On Monday, March 19, 2012 3:47:48 AM UTC-4, Дамян Станчев wrote:
>
> Hi guys,
> I had the following code, that I was using to create reports and they 
> appeared in my client center. Now when the old API is deprecated I have 
> problems doing the same thing. I need to be able to create keyword 
> performance reports from a PHP script and they must appear in the client 
> center. Any ideas how to do this with the new API?
>
> P.S Until now I managed to create a ReportDefinition, but what is the way 
> to use the created ReportDefinition object after that?
>
> OLD CODE:
> $reportDefinitionService = $user->GetReportDefinitionService('v201008');
> $adGroupId = (float) $_GET['id'];
> $adGroupName = $_GET['name'];
>
> # Create ad group predicate.
> $adGroupPredicate = new Predicate();
> $adGroupPredicate->field = 'AdGroupId';
> $adGroupPredicate->operator = 'EQUALS';
> $adGroupPredicate->values = array($adGroupId);
>
> # Create selector.
> $selector = new Selector();
> $selector->fields = array("AdGroupName", "KeywordText", "Impressions", 
> "Ctr", "AveragePosition");
> $selector->predicates = array($adGroupPredicate);
>
> # Create report definition.
> $reportDefinition = new ReportDefinition();
> $reportDefinition->reportName = 'NEW Keywords performance report 
> '.$adGroupName.' for adgroup #' . $adGroupId . ' @' . time();
> $reportDefinition->reportType = 'KEYWORDS_PERFORMANCE_REPORT';
> $reportDefinition->downloadFormat = 'CSVFOREXCEL';
> $reportDefinition->dateRangeType = 'LAST_7_DAYS';
> $reportDefinition->selector = $selector;
>
> # Create operations.
> $operation = new ReportDefinitionOperation();
> $operation->operand = $reportDefinition;
> $operation->operator = 'ADD';
>
> # Add report definition and download.
> $result = $reportDefinitionService->mutate(array($operation));
>

On Monday, March 19, 2012 3:47:48 AM UTC-4, Дамян Станчев wrote:
>
> Hi guys,
> I had the following code, that I was using to create reports and they 
> appeared in my client center. Now when the old API is deprecated I have 
> problems doing the same thing. I need to be able to create keyword 
> performance reports from a PHP script and they must appear in the client 
> center. Any ideas how to do this with the new API?
>
> P.S Until now I managed to create a ReportDefinition, but what is the way 
> to use the created ReportDefinition object after that?
>
> OLD CODE:
> $reportDefinitionService = $user->GetReportDefinitionService('v201008');
> $adGroupId = (float) $_GET['id'];
> $adGroupName = $_GET['name'];
>
> # Create ad group predicate.
> $adGroupPredicate = new Predicate();
> $adGroupPredicate->field = 'AdGroupId';
> $adGroupPredicate->operator = 'EQUALS';
> $adGroupPredicate->values = array($adGroupId);
>
> # Create selector.
> $selector = new Selector();
> $selector->fields = array("AdGroupName", "KeywordText", "Impressions", 
> "Ctr", "AveragePosition");
> $selector->predicates = array($adGroupPredicate);
>
> # Create report definition.
> $reportDefinition = new ReportDefinition();
> $reportDefinition->reportName = 'NEW Keywords performance report 
> '.$adGroupName.' for adgroup #' . $adGroupId . ' @' . time();
> $reportDefinition->reportType = 'KEYWORDS_PERFORMANCE_REPORT';
> $reportDefinition->downloadFormat = 'CSVFOREXCEL';
> $reportDefinition->dateRangeType = 'LAST_7_DAYS';
> $reportDefinition->selector = $selector;
>
> # Create operations.
> $operation = new ReportDefinitionOperation();
> $operation->operand = $reportDefinition;
> $operation->operator = 'ADD';
>
> # Add report definition and download.
> $result = $reportDefinitionService->mutate(array($operation));
>

-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
http://adwordsapi.blogspot.com
http://groups.google.com/group/adwords-api
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

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


Re: Creating keyword performace report usind adwords API

2012-03-19 Thread Ewan Heming
It's actually quite easy as the main difference is that you don't need to 
create a report before downloading it anymore. Something like the following 
should work (although I haven't tested it):

$adGroupId = (float) $_GET['id'];
$adGroupName = $_GET['name'];

# Create ad group predicate.
$adGroupPredicate = new Predicate();
$adGroupPredicate->field = 'AdGroupId';
$adGroupPredicate->operator = 'EQUALS';
$adGroupPredicate->values = array($adGroupId);

# Create selector.
$selector = new Selector();
$selector->fields = array("AdGroupName", "KeywordText", "Impressions", 
"Ctr", "AveragePosition");
$selector->predicates = array($adGroupPredicate);

# Create report definition.
$reportDefinition = new ReportDefinition();
$reportDefinition->reportName = 'NEW Keywords performance report 
'.$adGroupName.' for adgroup #' . $adGroupId . ' @' . time();
$reportDefinition->reportType = 'KEYWORDS_PERFORMANCE_REPORT';
$reportDefinition->downloadFormat = 'CSVFOREXCEL';
$reportDefinition->dateRangeType = 'LAST_7_DAYS';
$reportDefinition->selector = $selector;

// You don't need to create a report, just download it:
$fileName = 'INSERT_OUTPUT_FILE_NAME_HERE';
$path = dirname(__FILE__) . '/' . $fileName;
  $options = array('version' => 'v201109', 'returnMoneyInMicros' => TRUE);
  ReportUtils::DownloadReport($reportDefinition, $path, $user, $options);

-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
http://adwordsapi.blogspot.com
http://groups.google.com/group/adwords-api
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

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


Creating keyword performace report usind adwords API

2012-03-19 Thread Дамян Станчев
Hi guys,
I had the following code, that I was using to create reports and they 
appeared in my client center. Now when the old API is deprecated I have 
problems doing the same thing. I need to be able to create keyword 
performance reports from a PHP script and they must appear in the client 
center. Any ideas how to do this with the new API?

P.S Until now I managed to create a ReportDefinition, but what is the way 
to use the created ReportDefinition object after that?

OLD CODE:
$reportDefinitionService = $user->GetReportDefinitionService('v201008');
$adGroupId = (float) $_GET['id'];
$adGroupName = $_GET['name'];

# Create ad group predicate.
$adGroupPredicate = new Predicate();
$adGroupPredicate->field = 'AdGroupId';
$adGroupPredicate->operator = 'EQUALS';
$adGroupPredicate->values = array($adGroupId);

# Create selector.
$selector = new Selector();
$selector->fields = array("AdGroupName", "KeywordText", "Impressions", 
"Ctr", "AveragePosition");
$selector->predicates = array($adGroupPredicate);

# Create report definition.
$reportDefinition = new ReportDefinition();
$reportDefinition->reportName = 'NEW Keywords performance report 
'.$adGroupName.' for adgroup #' . $adGroupId . ' @' . time();
$reportDefinition->reportType = 'KEYWORDS_PERFORMANCE_REPORT';
$reportDefinition->downloadFormat = 'CSVFOREXCEL';
$reportDefinition->dateRangeType = 'LAST_7_DAYS';
$reportDefinition->selector = $selector;

# Create operations.
$operation = new ReportDefinitionOperation();
$operation->operand = $reportDefinition;
$operation->operator = 'ADD';

# Add report definition and download.
$result = $reportDefinitionService->mutate(array($operation));

-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
http://adwordsapi.blogspot.com
http://groups.google.com/group/adwords-api
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

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