【问题标题】:Snapchat ads api - datetime & timezone for api calls results in failure due to timezone changesSnapchat 广告 api - api 调用的日期时间和时区由于时区更改而导致失败
【发布时间】:2019-10-02 15:03:21
【问题描述】:

我正在开发 Snapchat 广告 API。 (为大查询编写连接器)。目前我以一天的粒度获得指标(性能统计数据)。我将以下作为查询参数传递给请求 URL。

帐户时区:美国/洛杉矶

我成功地使用了以下日期格式来检索数据。

2019-03-11T00:00:00.000-07:00 2019-03-12T00:00:00.000-07:00

payload = {
  'granularity': 'DAY',
  'start_time': start_datetime,
  'end_time': end_datetime,
  'fields': fields
}

但是,当我查询 2019-03-10 的日期时(我认为是夏令时调整导致了这种情况),它给了我以下错误

{'request_status': 'ERROR', 'request_id': 'xxxxxxxx', 'debug_message': "Unsupported Stats Query: Timeseries queries with DAY granularity must have a start time that is the start of day (00:00:00) for the account's timezone. This account's timezone  is: America/Los_Angeles", 'display_message': "We're sorry, but the data provided in the request is incomplete or incorrect", 'error_code': 'E1008'}

我还尝试通过调整夏令时调整来进行查询。但不成功。

2019-03-11T00:00:00.000-08:00 2019-03-12T00:00:00.000-08:00

2019-03-11T00:00:00.000-06:00 2019-03-12T00:00:00.000-06:00

没有可用的文档:https://developers.snapchat.com/api/docs/

任何帮助将不胜感激。谢谢!

【问题讨论】:

    标签: python python-3.x datetime snapchat


    【解决方案1】:

    您可以尝试这种格式。开始日期仍然相同,但我们将夏令时应用于结束日期。

    2019-03-11T00:00:00.000-07:00 2019-03-12T00:00:00.000-08:00
    

    对我有用,希望对你有帮助。

    【讨论】:

      【解决方案2】:

      我也无法让“DAY”粒度为我工作。这对我有用:

      params = {
          "granularity": "TOTAL",
          "start_time": "2019-03-11T00:00:00.000-07:00",
          "end_time": "2019-03-12T00:00:00.000-07:00",
      }
      

      然后你的想法是你可以遍历一个日期范围并以这种方式获取你的统计数据。

      【讨论】:

      • 检查你的时区是否有加号或减号,如果有加号,你应该转义它
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-06-06
      • 2012-08-07
      • 1970-01-01
      • 2013-09-21
      • 2019-02-27
      • 2014-11-10
      • 1970-01-01
      相关资源
      最近更新 更多