Hi ,
I am new to PHP and Adwords API. Can someone please post an example
(using PHP) on how to get the CampaignStats given a Campaign ID .I can
get it for all campaigns, but not sure how to use the Selector for
Active Campaigns.  Please see code snippet below:-

$campaignService = $user->GetCampaignService('v200909');
  $today =  date('Y-m-d');

$start = mktime(0,0,0,date("m"),date("d")-15,date("Y"));
$end = mktime(0,0,0,date("m"),date("d")-1,date("Y"));

$start_date = date("Y-m-d", $start);
$end_date = date("Y-m-d", $end);

$campaignId = <insert_campaign_ID_here>;

// Create selector.
  $selector = new CampaignSelector();
  $selector->ids = array($campaignId);
  $page = $campaignService->get($selector);

//Not sure how to use the selector here
 $campstats =  new Stats();
  $campstats->start_date = $start_date;
  $campstats->end_date = $end_date;

//Not sure how to use the selector here
  $page = $campaignService->get($campstats);

 if (isset($page->entries)) {
    foreach ($page->entries as $campaign) {
        echo 'Campaign ID:' . $campaign->id . ' Campaign name:' . $campaign-
>name .' Campaign startdate:"' . $campaign->startDate."<br>";
        echo 'Campaign Clicks:' . $campaign->stats->clicks ."<br>";  //this
is empty at present
        echo 'Campaign cost:' . $campaign->stats->cost ."<br>";  //this is
empty at present

thanks and any info is appreciated..
-Jeya
-- 
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