Facebook PHP API getReachEstimate

209 views Asked by At

I am quite a beginner and trying to learn to apply some things in Facebook PHP SDK, but there are some things poorly explained in the documentation.

My goal is to get number of users who say are interested in both "socker" and "football".

I think a function getReachEstimate($array, $array) does exactly that, my approach would be.

use FacebookAds\Object\ReachEstimate;
use FacebookAds\Object\Fields\ReachEstimateFields;
use FacebookAds\Object\AdAccount;

$account = new AdAccount($account_id);
$reachEstimate = $account->getReachEstimate($SOME_ARRAY, $SOME_ARRAY2));

I looked in the source of SDK and this function takes two arrays, but it is nowhere explained what are these arrays must look like. If anyone has any suggestions, please let me know. Thank you.

1

There are 1 answers

0
codingquark On

The first parameter seems irreverent to me. But I'm not sure. Will update the answer when I find. Meanwhile here's how to do it:

Suppose following are your parameters:

$params = [
  'targeting_spec' => ['geo_locations' => ['countries' => ['US']]]
];
$fields = [];

Then call it in the following way:

$adAccount = new AdAccount($adAccountId);
$adAccount->getReachEstimate($fields, $params)->getData();

So, put your Targeting Spec in $params and the calls

Hope this helps!