4

I want to show the daily estimated reach using fb api.

I have tried below code :-

$ch = curl_init();
   curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
   curl_setopt($ch, CURLOPT_TIMEOUT, 60);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
   curl_setopt($ch, CURLOPT_USERAGENT, 'facebook');

$url_en = urlencode("{'geo_locations':{'countries': ['US'],},'age_min':20,'age_max':24}");


   curl_setopt($ch, CURLOPT_URL, "https://graph.facebook.com/v2.2/act_1375199556085956/reachestimate?access_token=ACCESS TOKEN&targeting_spec=".$url_en);

   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);
   curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
   curl_setopt($ch, CURLOPT_HEADER, 0);
   //curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

   $data = curl_exec($ch);

But getting the response data below :-

"data": {
      "users": 14600000,
      "bid_estimations": [
         {
            "unsupported": false,
            "location": 3,
            "cpa_min": 79,
            "cpa_median": 145,
            "cpa_max": 195,
            "cpc_min": 45,
            "cpc_median": 70,
            "cpc_max": 87,
            "cpm_min": 8,
            "cpm_median": 20,
            "cpm_max": 27
         }
      ],
      "estimate_ready": true
   }
}

BUT, I want result like:

enter image description here

Please help me with this.

evanwong
  • 5,054
  • 3
  • 31
  • 44
Khushboo
  • 1,819
  • 1
  • 11
  • 17

2 Answers2

2

Added in v2.9

/<AD_ACCOUNT>/delivery_estimate

or

/<AD_SET>/delivery_estimate

Ref: https://developers.facebook.com/docs/marketing-api/buying-api/targeting/v2.9

atoo
  • 123
  • 9
1

The API only supports monthly estimates according to the documentation

Elmo
  • 19
  • 1
  • 6
  • 1
    Thanks Elmo. How do you get the range number of users (13000-24000) for the monthly reach? which fields are they in the response? – fredy Mar 19 '16 at 02:58