我正在製作一堆顯示不同廣告系列數據的不同儀表板。在儀表板上使用facebook營銷API的用戶數量限制
我很擔心#17 User request limit reached
,因爲我已經這麼多次了。
我使用Facebook的API市場以獲取特定廣告活動見解,但我不明白,爲什麼我最終得到的極限
我使用的是單個用戶的訪問令牌,以避免用戶登錄在Facebook上查看儀表板。
我用這一段腳本,深入分析數據,並存儲在MySQL
Api::init(
'XXXX',
'XXXX',
'XXXX'
);
$api = Api::instance();
$account = new AdAccount('act_XXXX');
$campaign_params = array(
'limit' => 200,
'time_range' => array(
'since' => date("Y-m-d", strtotime($_GET["date_from"])),
'until' => date("Y-m-d", strtotime($_GET["date_to"])),
),
'level' => "adset",
);
$campaign_res = $account->getInsights(array("ad_name", "adset_name", "adset_id", "inline_link_clicks", "spend", "campaign_id", "campaign_name", "unique_clicks", "cost_per_inline_link_click", "ctr", "cpm", "cpp", "reach", "impressions"), $campaign_params);
$pagesArray = array();
foreach($campaign_res as $c_data) {
$campaign = $c_data->exportData();
$pos = strpos(utf8_decode($campaign["campaign_name"]), "Mød");
if($pos !== false) {
$chars = array("æ", "ø", "å");
$replace = array("ae", "oe", "aa");
$decoded_name = strtolower(str_replace($chars, $replace, utf8_decode($campaign["campaign_name"])));
$decoded_name = explode(" - ", $decoded_name);
$lpage_pos = strripos($decoded_name[0], $_GET["lpage"]);
if($lpage_pos !== false) {
$adset = new AdSet($campaign["adset_id"]);
$adset->read(array(
AdSetFields::NAME,
AdSetFields::CONFIGURED_STATUS,
AdSetFields::EFFECTIVE_STATUS,
));
$nameArray = preg_split("/ - /", $campaign["adset_name"]);
if(trim(strtolower($nameArray[1])) == "msn") {
$status = strtolower($adset->{AdSetFields::EFFECTIVE_STATUS}.PHP_EOL);
array_push($pagesArray, array("pageName" => trim(strtolower($nameArray[0])), "pageSpend" => $campaign["spend"]));
$delete_sql = "DELETE FROM msn_ad_data WHERE adset_id = ". $campaign["adset_id"] ." AND type='facebook'";
$delete_sth = $db->dbh->prepare($delete_sql);
$delete_sth->execute();
$sql = "INSERT INTO msn_ad_data (campaign_id, campaign_name, adset_id, adset_name, amount_spent, reach, impressions, date_from, date_to, clicks, cpc, ctr, cpm, id_campaign_shortname, pagename, id_name, form_name, status, type) VALUES (". $campaign["campaign_id"] .", '". $campaign["campaign_name"] ."', '". $campaign["adset_id"] ."', '". $campaign["adset_name"] ."', '". $campaign["spend"] ."', '". $campaign["reach"] ."', '". $campaign["impressions"] ."', '". $campaign["date_start"] ."', '". $campaign["date_stop"] ."', '". $campaign["unique_clicks"] ."', '". $campaign["cost_per_inline_link_click"] ."', '". $campaign["ctr"] ."','". $campaign["cpm"] ."', '". $_GET["lpage"] ."', '". $nameArray[0]."-".$nameArray[3] ."', '". str_replace($chars, $replace, trim(strtolower(utf8_decode($nameArray[0]."-".$nameArray[3])))) ."', '". str_replace($chars, $replace, strtolower(utf8_decode($nameArray[2]))) ."', '". $status ."', 'facebook')";
$sth = $db->dbh->prepare($sql);
$sth->execute();
}
}
在將運行此腳本以defalt時間範圍內的儀表板的初始加載,則有可能選擇儀表板上的特定日期範圍,用戶希望查看來自fx的數據最後14天 - 它會再次運行該腳本。
我對這個主題感到擔憂的是,大約有20個不同的儀表板會顯示來自20個不同活動的數據。
是每個APPID或每個用戶令牌/ IP的限制。如果有20個不同的IP,那麼它是20 x 200個呼叫=每60分鐘4000個呼叫,還是每個令牌只有200個呼叫?
我似乎無法找到更好的方法來即時獲取洞察數據。