skip to Main Content

I’m trying to use the Facebook graph api for my ad account to get the insights of a specific date. I believe date is the correct parameter to use. Here is Facebook’s documentation for ad account insights https://developers.facebook.com/docs/marketing-api/reference/ad-account/insights/

Here is the url I am attempting to use:

https://graph.facebook.com/v2.6/act_ACCOUNT_ID/insights?access_token=MY_ACCESS_TOKEN&time_range={"since":"2016-08-09","until":"2016-08-09"}&fields=account_id%2Cspend%2Cimpressions%2Ctotal_actions&method=get&pretty=0&sdk=joey

This is the response I get:

{"error":{"message":"(#100) Must be a date representation in the format YYYY-MM-DD","type":"OAuthException","code":100,"fbtrace_id":"HEFP4SeNfWa"}}

4

Answers


  1. act_account_id/insights?time_range={'since':'2016-10-17','until':'2016-10-17'}&fields=reach
    
    Login or Signup to reply.
  2. I don’t know concerning the single or double quotes. For me, the single quotes worked this way :

    act_account_id/insights?time_range={'since':'2016-10-17','until':'2016-10-17'}&fields=reach
    

    However, using Google Apps SCript and UrlFetchApp.fetch method, I had to use encodeURIComponent on the time range parameters to get it to work.

    Login or Signup to reply.
  3. the best way to use this is

    https://graph.facebook.com/v2.6/act_ACCOUNT_ID?fields=insights.time_range({"since":"2016-08-09","until":"2016-08-09"}){account_id,spend,impressions,total_actions}&access_token=MY_ACCESS_TOKEN&method=get&pretty=0&sdk=joey
    
    Login or Signup to reply.
  4. You can use this too. This is URL encoded:

    time_range=%7B’since’:’2020-04-06′,’until’:’2020-04-09’%7D

    but keep in mind that above line only works with the combination of:

    time_increment=1

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search