0
我嘗試從Facebook營銷API獲取一些數據。我得到的結果通常是正確的,但我有數據問題。看起來參數time_range
不起作用。爲什麼`time_range`在Facebook API的請求中不起作用?
https://graph.facebook.com/v2.7/act_<MY_ACT>/ads?fields=name,adcreatives{object_story_id},insights{spend,unique_clicks},effective_status¶ms=time_range={%22since%22:%222016-11-15%22,%22until%22:%222016-11-17%22}&limit=2000&access_token=<MY_TOKEN>
結果:
{
"data": [
{
"name": "xx",
"adcreatives": {
"data": [
{
"id": "xx"
}
]
},
"effective_status": "DISAPPROVED",
"id": "xx"
},
{
"name": "xx",
"adcreatives": {
"data": [
{
"id": "xx"
}
]
},
"insights": {
"data": [
{
"spend": xx,
"unique_clicks": "34",
"date_start": "2016-10-19",
"date_stop": "2016-11-17"
}
],
"paging": {
"cursors": {
"before": "MAZDZD",
"after": "MAZDZD"
}
}
},
"effective_status": "CAMPAIGN_PAUSED",
"id": "xx"
},...}
我試圖對其進行編碼,寫不同的方式,但每次的結果都是從上個月開始,所以DATE_START是二零一六年十月十九日和date_stop是2016- 10-17,而不是從範圍我把查詢作爲parametr。我該如何解決它?
編輯: 我也嘗試過的,而不是¶ms=time_range={%22since%22:%222016-11-15%22,%22until%22:%222016-11-17%22}
像&date_preset=yesterday
(昨天或文檔中列出的其他正確的值),但我仍然得到完全相同的日期......
好的找到部分解決方案。 'date_preset'的值應該放在'insights.'之後,所以類似這樣的工作:'/ ads?fields = name,adcreatives {object_story_id},insights.date_preset(yesterday){spend,unique_clicks},effective_status&limit = 2000' 。但我仍然不知道如何從未定義的時間範圍獲取值... – jjankowiak