Hi,

I tried to modify the PHP sample code for get_all_campaigns.php
(http://code.google.com/p/adwords-api-php-samples/source/browse/trunk/
src/get_all_campaigns.php) to retrieve getCampaignStats but only got
an error. How can I retrieve the StatsRecord[] response for a given
campaign?

Here is the code I used:

require_once('soapclientfactory.php');

# Define SOAP headers.
$headers = $this->define_soap_headers(); //this part works fine - the
headers are correctly set

# Set up service connection.

$namespace = 'https://adwords.google.com/api/adwords/v12';
$campaign_service =
  SoapClientFactory::GetClient($namespace . '/CampaignService?wsdl',
'wsdl');
$campaign_service->setHeaders($headers);
$debug = 0;


$campaignIds = array(1234567]);

#
 $start = '2008-01-01T00:00:00Z';

#
 $end = '2008-12-01T00:00:00Z';

#
$request_xml =
  '<getCampaignStats><campaignIds>'.$campaignIds.'</
campaignIds><startDay>'.$start.'</startDay><endDay>'.$end.'</endDay></
getCampaignStats>';
$campaign_stats = $campaign_service->call('getCampaignStats',
$request_xml);
$campaign_stats = $campaign_stats['getCampaignStatsReturn'];

if ($debug) $this->show_xml($campaign_service);
if ($campaign_service->fault) $this->show_fault($campaign_service);

# Convert to a list if we get back a single object.
if (!$campaign_stats[0]) {
  $campaign_stats = array($campaign_stats);
}

 print_r($campaign_stats);

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to