Retrieve budget spent and end date for all billing accounts

100 views
Skip to first unread message

Mathieu Dubreuil

unread,
Sep 21, 2016, 1:58:04 PM9/21/16
to AdWords API Forum
Hi,

I am trying to get all the budgets from all billing accounts used under an MCC account. I saw that I should use the BudgetOrderService to get BudgetOrders, but it returns me an empty page. I can get the billing accounts from the BudgetOrderService->getBillingAccounts, what am I doing wrong? I am using the most recent version of the API and had nothing before, I am also whitelisted.

Here is my code (PHP) : 

 public function getBudgets(AdWordsUser $user) {
        
        // Get the service, which loads the required classes.
        $budgetOrderService = $user->GetService('BudgetOrderService', ADWORDS_VERSION);

        // Create selector.
        $selector = new Selector();
        $selector->fields = array('id', 'spendingLimit', 'endDateTime');
        
        // Create paging controls.
        $selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
        
        do {
            // Make the get request.
            $page = $budgetOrderService->get($selector);

            print_r($page); // Here it says BudgetOrderPage Object ( [entries] => [totalNumEntries] => 0

            // Show the information for all budgets
            if (isset($page->entries)) {
                foreach ($page->entries as $budgetOrder) {
                    echo $budgetOrder->id;
                    echo $budgetOrder->spendingLimit;
                    echo $budgetOrder->endDateTime;
                }   
            }
        
            // Advance the paging index.
            $selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
        } while ($page->totalNumEntries > $selector->paging->startIndex);
    }
}

Anthony Madrigal

unread,
Sep 21, 2016, 3:04:46 PM9/21/16
to AdWords API Forum
Hi Mathieu,

Could you please supply me with your SOAP request and response via reply privately to author? This will help me see if there is anything you are doing incorrectly.

Thanks,
Anthony
AdWords API Team

Martin Eisenführer

unread,
Mar 2, 2017, 3:07:46 PM3/2/17
to AdWords API Forum
hi, 

any solutions for this request ?

have the same problem. Working with v201609 and 

public function getBudgets(AdWordsSession $session) {
     $bos = (new AdWordsServices())->get($session, BudgetOrderService::class);
      ....
}

all the other stuff the same

thanks for help
Martin

Shwetha Vastrad (AdWords API Team)

unread,
Mar 2, 2017, 4:33:57 PM3/2/17
to AdWords API Forum
Hi Martin,

Could you check if the clientCustomerId specified in the request header belongs to your client account and not your manager account? Could you provide the SOAP request and response logs so I can take a look? Please use Reply privately to author when responding. 

Thanks,
Shwetha, AdWords API Team.
Reply all
Reply to author
Forward
0 new messages