hborras / twitter-php-ads-sdk

A Twitter supported and maintained Ads API SDK for PHP.
55 stars 41 forks source link

Expect time to be midnight in the account's local timezone for day granularity [paramete #66

Closed ghost closed 4 years ago

ghost commented 4 years ago

Hi Borras,

I'm trying to get Ads data, but I'm getting this error.

I'm London UK -

Array ( [0] => DateTime Object ( [date] => 2018-09-25 00:00:00.000000 [timezone_type] => 3 [timezone] => UTC )

[1] => DateTime Object
    (
        [date] => 2018-09-26 00:00:00.000000
        [timezone_type] => 3
        [timezone] => UTC
    )
hborras commented 4 years ago

Hello!

Could you send the complete Request and Response?

Thanks

ghost commented 4 years ago

Fixed it just now It was my mistake, sorry.

Thanks though

groover99 commented 4 years ago

@eblucas-uk How you solved this error. I am also getting this error. Twitter Account's timezone is 'Australia/Sydney'

My post params are like

request: {
    params: {
      start_time: '2018-01-01T00:00:00Z',
      entity_ids: [Array],
      end_time: '2020-07-10T00:00:00Z',
      placement: 'ALL_ON_TWITTER',
      account_id: '<account-id>',
      granularity: 'DAY',
      entity: 'CAMPAIGN',
      metric_groups: [Array]
    }
  }
}
ghost commented 4 years ago

Hi @groover99

You need to create the date object setting the TimeZone for the same as your Twitter account, in your case Australia/Sydney

        $startDate = new \DateTime('2020-01-01 00:00:00', new \DateTimeZone('Europe/London'));

        $endDate = new \DateTime('2020-02-10 00:00:00', new \DateTimeZone('Europe/London'));

Hope this helps.