I'm have just installed Google API on my server. The aim is to get daily
expense of the account. I was playing around with 'GetCampaigns.php'
example, which use 'CampaignService' service. This service has different
fields such as Id, Name, Amount and many others. I want the code below to
grab all campaigns and print their name and amount spent.
<?php
require_once dirname(dirname(__FILE__)) . '/init.php';
function GetCampaignsExample(AdWordsUser $user) {
$campaignService = $user->GetService('CampaignService', ADWORDS_VERSION);
$selector = new Selector();
$selector->fields = array('Name', 'Amount');
$selector->ordering[] = new OrderBy('Name', 'ASCENDING');
$selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
do {
$page = $campaignService->get($selector);
if (isset($page->entries)) {
foreach ($page->entries as $campaign) {
printf("Campaign with name '%s' with amount '%s' was found.\n",
$campaign->name, $campaign->amount);
}
} else {
print "No campaigns were found.\n";
}
$selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
} while ($page->totalNumEntries > $selector->paging->startIndex);
}
if (__FILE__ != realpath($_SERVER['PHP_SELF'])) {
// return;
}
try {
$user = new AdWordsUser();
$user->LogAll();
GetCampaignsExample($user);
} catch (Exception $e) {
printf("An error has occurred: %s\n", $e->getMessage());
}
?>
However, I don't understand a reason why the page outputs:
Notice: Undefined property: Campaign::$amount in
/public_html/adwords/examples/AdWords/v201409/BasicOperations/GetCampaigns.php
on line 17 Campaign with name 'My Campaign' and amount '' was found.
The name is successfully retrieved but the amount is not.
May be somebody has a complete solution to get total budget spent for a
date range?
Thank you
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 [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
---
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 [email protected].
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/1f471995-3703-498e-ba2a-a212e5498797%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.