2015-02-10 47 views
1

我可以通過API成功獲取特定日期之間的廣告系列統計信息,但是我需要按日期而不是總數來細分日期。Facebook廣告api - 按日獲取統計信息

我可以看到它適用於頁面洞察API,但似乎沒有關於廣告洞察API的文檔。

我使用以下調用來獲取日期之間的總數。

https://graph.facebook.com/v2.2/act_ /統計?=的access_token START_TIME & & = = END_TIME

但是我無法找到的文檔通過一天把它分解成每天一個查詢。

這個答案有一個解決方案,但沒有奏效。

Downloading Facebook ads statistics in background (no web browser)

謝謝!

============================================== =====

新信息:

所以我可以用time_increment = 1一天拿到一個破發下來然而,隨着「date_preset」這只是作品,但是我想設置一個日期範圍。我使用的是最新的API

https://graph.facebook.com/v2.2/act_ {$這個 - >帳戶ID}/reportstats

使用 'time_ranges' 無論使用time_increment = 1

使用 'date_preset' 如last_28_days做的工作將合併數據用time_increment。

使用 'TIME_INTERVAL' 與我的時區的午夜時戳(如文檔的建議)引發以下錯誤:

[錯誤] => stdClass的對象 ( [消息] =>(#100)的「 TIME_START」和 「time_stop」 必須是整數。 [型] => OAuthException [代碼] => 100 )

它們是整數!這是我的完整發布數據

$postData = array(

     'async'=>'true', 

     'data_columns'=>$data_columns, 
     /* 
     'time_ranges'=>array(
      array(
       'day_start'=>array(
        'day'=>$startDate->format("d"), 
        'month'=>$startDate->format("m"), 
        'year'=>$startDate->format("Y"), 
       ), 
       'day_stop'=>array(
        'day'=>$endDate->format("d"), 
        'month'=>$endDate->format("m"), 
        'year'=>$endDate->format("Y"), 
       ), 
      ), 
     ), 
    */ 
     'actions_group_by'=>array('action_type'), 




     'time_interval'=>array(
       'time_start'=>$startDate->getTimestamp() , 
       'time_stop'=>$endDate->getTimestamp(), 
      ), 

     //'date_preset' => 'last_28_days', 

     'time_increment'=>'1', 

     'filters'=>$filters, 

     'access_token'=>$this->access_token 


     ); 
+0

嘗試使用當前報告API,而不是(在/統計終點是很舊,早於所有在Facebook的自己的接口目前的報道): https://developers.facebook.com/docs/marketing-api/adreportstats/v2.2 - 專門查看'time_increment',它可以讓你按天分組 – Igy 2015-02-10 16:22:46

+0

我正在使用新的API,我相信新的API是隻是一個包裝,它仍然調用/統計URL。不確定在新的API調用中將time_increment放在哪裏文檔不明確 – user2760338 2015-02-14 12:01:46

+0

當'day_start'和'day_stop'使用'time_interval'時,出現錯誤:致命錯誤:未捕獲的異常'FacebookAds \ Http \ Exception \ AuthorizationException '使用他們自己的例子'消息'無效參數'! – user2760338 2015-02-14 13:30:46

回答

1

好吧,我不得不將格式time_interval更改爲time_range格式,它的工作!該文件說,時間戳將工作,但它沒有,這工作:

'time_interval'=>array(
       'day_start'=>array(
        'day'=>$startDate->format("d"), 
        'month'=>$startDate->format("m"), 
        'year'=>$startDate->format("Y"), 
       ), 
       'day_stop'=>array(
        'day'=>$endDate->format("d"), 
        'month'=>$endDate->format("m"), 
        'year'=>$endDate->format("Y"), 
       ), 
       ), 
相關問題