Reputation: 174
I'm attempting to just get the spend for specific Ad Accounts from the previous day. Whenever I send up the request:
$api = Api::instance();
$account = new AdAccount('act_<account_id>');
$params = array(
'level' => 'account',
'date_preset' => 'yesterday',
'fields' => ['spend', 'account_id'],
);
$insights = $account->getInsights(array(), $params);
print_r($insights);
I get a large protected object back and can't seem to find any documentation as to how to access the actual requested data.
Upvotes: 0
Views: 613
Reputation: 174
//Get HLG Ad Spend
$account = new AdAccount('act_10153795481711178');
$params = array(
'level' => 'account',
'date_preset' => 'yesterday',
'fields' => ['spend', 'account_id']
);
$insights = $account->getInsights(array(), $params);
$hlgData = $insights->getResponse()->getContent()['data'];
if(isset($hlgData[0]))
{
$hlgSpendFB = $hlgData[0]['spend'];
}else{
$hlgSpendFB = "0";
}
Above is how I was able to get the data from the Ad Account for spend from previous day. After digging through the object itself I was able to find the getter functions that procured the data requested.
Upvotes: 1