我想要检索Feed的所有事件并收集事件详细信息。像这样,我正在查询Feed:
// instantiate
$facebook = new Facebook($config);
$pagefeed = $facebook->api("/" . $pageid . "/feed");
foreach($pagefeed['data'] as $post) {
// check if post type is a link
if ($post['type'] == 'event') {
// call API to retrieve the event details
}
}
如您所见,我需要为每个事件发送一个请求。我可以避免使用oData中的“expand”命令吗?
干杯
答案 0 :(得分:3)
// init app with app id and secret
FacebookSession::setDefaultApplication( FB_APP_ID, FB_SECRET);
// If you're making app-level requests:
$session = FacebookSession::newAppSession();
// To validate the session:
try {
$session->validate();
} catch (FacebookRequestException $ex) {
// Session not valid, Graph API returned an exception with the reason.
} catch (\Exception $ex) {
// Graph API returned info, but it may mismatch the current app or have expired.
}
try {
$request = new FacebookRequest(
$session,
'GET',
// get all events of a Page, ?fields= let you choose which fields you want the Graph to return
'/' . FB_ID . '/events?fields=id,end_time,cover,description,is_date_only,location,name,start_time&since='
. strtotime('-1 year') . '&until=' . strtotime('+1 year')
. '&limit=10&locale=de_DE&date_format=d. M, y H:m'
);
$response = $request->execute();
$graphObject = $response->getGraphObject()->asArray();
// handle the result -> returns an indexed array without key
$objectData = $graphObject['data'];
如果你知道怎么做就很简单......; - )
希望这也有助于其他人的争吵。