While calling getInsights() method,it gives an object.so i want to access some data from it.
Here is the api call
$account->getInsights($fields, $params);
echo '<pre>';print_r($resultArr);die;
it will gives result like
FacebookAdsCursor Object
(
[response:protected] => FacebookAdsHttpResponse Object
(
[request:protected] => FacebookAdsHttpRequest Object
(
[client:protected] => FacebookAdsHttpClient Object
(
[requestPrototype:protected] => FacebookAdsHttpRequest Object
(
Thanks in advance.
4
Answers
The following should work:
If you have more than one object in the cursor, you can just loop over it:
In this case, if you set the implicitFetch option to true by default with:
you will be sure you are looping over all the results.
I using this piece of code and It works for me, I hope works for you …
Not sure if my method differs from Angelina’s because it’s a different area of the SDK or if it’s because it’s been changed since her answer, but below is the code that works for me, and hopefully will be useful for someone else:
Calling getArrayCopy returns an array of AbstractObjects and then calling getData returns an an array of the objects props.
Maybe try:
and then go for the usual stuff: