Facebook 图表的多个页面 ID API

Multiple Page IDs for Facebook Graph API

我正在为这个 php 问题苦苦挣扎,但找不到解决方案。

现在,下面的代码正在显示一个特定 Facebook 页面的所有事件,其中 $fb_page_id : "357734517342";

我的问题是,如果我想从多个 Facebook 页面 ID 显示,我应该怎么做?

PS:我尝试将 /?ids=page1id,page2id/ 添加到 json,但它不起作用。

我有以下代码:

session_start();
$fb_page_id = preg_replace( '/[^0-9]/', '', isset($_GET['fb_page_id']) ? $_GET['fb_page_id'] : "");
$fb_page_id = !empty($fb_page_id) ? $fb_page_id : "357734517342";

$access_token="<MY ACCESS TOKEN>";

$fields="id, name, description, location, venue, timezone, start_time, cover";
$limit=5;
$year_range = 1;

if($show=="all"){
    // automatically adjust date range
    // human readable years
    $since_date = date('Y-01-01', strtotime('-' . $year_range . ' years'));
    $until_date = date('Y-12-31', strtotime('+' . $year_range . ' years'));
}

// json link
$json_link = "https://graph.facebook.com/{$fb_page_id}/events/attending/?fields={$fields}&access_token={$access_token}&since={$since_unix_timestamp}&until={$until_unix_timestamp}&limit={$limit}";

$json = file_get_contents($json_link);
$obj = json_decode($json, true, 512, JSON_BIGINT_AS_STRING);

$next_page = isset($obj['paging']['next']) ? $obj['paging']['next'] : "";
$_SESSION['EVENTS_NEXT_PAGE_' . $fb_page_id]=$next_page;
$_SESSION['EVENTS_SET_NUM_' . $fb_page_id]=1;

我认为您应该要求以逗号分隔的 ID 作为 GET 变量之一:

$json_link = "https://graph.facebook.com/events/attending/?ids=PAGE1_ID,PAGE2_ID&fields={$fields}&access_token={$access_token}&since={$since_unix_timestamp}&until={$until_unix_timestamp}&limit={$limit}";