【问题标题】:Facebook API for ad accounts. How to use time_range parameter?用于广告帐户的 Facebook API。如何使用 time_range 参数?
【发布时间】:2016-08-10 18:54:18
【问题描述】:

我正在尝试将 Facebook 图形 API 用于我的广告帐户,以获取特定日期的见解。我相信日期是正确使用的参数。这是 Facebook 的广告帐户洞察文档https://developers.facebook.com/docs/marketing-api/reference/ad-account/insights/

这是我尝试使用的网址:

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

这是我得到的回复:

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

【问题讨论】:

    标签: facebook facebook-graph-api


    【解决方案1】:

    我不知道单引号或双引号。对我来说,单引号是这样工作的:

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

    但是,使用 Google Apps SCript 和 UrlFetchApp.fetch 方法,我必须在时间范围参数上使用 encodeURIComponent 才能使其工作。

    【讨论】:

      【解决方案2】:

      最好的使用方法是

      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
      

      【讨论】:

        【解决方案3】:
        act_account_id/insights?time_range={'since':'2016-10-17','until':'2016-10-17'}&fields=reach
        

        【讨论】:

        • 您能否解释一下原始问题中的时间范围有什么问题?是用双引号代替单引号吗?
        • 单或双无关紧要,只要您对其进行 url 编码即可
        • 无法获取非活动广告 ID 的数据..如何获取非活动广告洞察详细信息..
        【解决方案4】:

        您也可以使用它。这是 URL 编码的:

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

        但请记住,以上行仅适用于以下组合:

        time_increment=1

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2022-09-30
          • 2015-11-12
          • 1970-01-01
          • 1970-01-01
          • 2021-04-13
          相关资源
          最近更新 更多