Reputation: 4168
I made a page where you can see Event from a Public Page
The PHP Code
<?php
require 'src/facebook.php';
$facebook = new Facebook(array(
'appId' => 'ID',
'secret' => 'SECRET',
'cookie' => true,
));
try{
$events=$facebook->api('/PAGE/events?access_token=TOKEN');
}catch (FacebookApiException $e){
error_log($e);
}
foreach ($events["data"] as $event){
// Time
$startTime=strtotime($event["start_time"]);
// Only Upcoming events
if ((time()-$startTime)<=60*60*24*1 || $startTime>time()){
echo '<li><a href="#" id="'.$event["id"].'" class="event_link">
<img class="ui-li-thumb" src="https://graph.facebook.com/'.$event["id"].'/picture?type=small" width="70px;" height="100%" />
<h3 class="ui-li-heading">'.$event['name'].'</h3>
</a></li>';
}
}
?>
It is working Fine just I get the closest event last one in list
How can I change the order of output??(If it is possible ofcourse).
Upvotes: 0
Views: 666
Reputation: 4168
<?php
require 'src/facebook.php';
$facebook = new Facebook(array(
'appId' => 'ID',
'secret' => 'SECRET',
'cookie' => true,
));
$fql = "SELECT
name, pic, start_time
FROM
event
WHERE
eid IN ( SELECT eid FROM event_member WHERE uid = PAGE_ID )
AND
start_time >= now()
ORDER BY
start_time asc";
$param = array(
'method' => 'fql.query',
'query' => $fql,
'callback' => ''
);
$fqlResult = $facebook->api($param);
foreach( $fqlResult as $keys => $values ){
echo '<li><a href="#" id="'.$values["id"].'" class="event_link">
<img class="ui-li-thumb" src="'.$values['pic'].'" width="70px;" height="100%" />
<h3 class="ui-li-heading">'.$values['name'].'</h3>
</a></li>';
}
?>
SOLVED!
Upvotes: 1
Reputation: 20753
You'll have to use fql
for that. FQL - Event
So that with in the query you could use, ORDER BY
, to sort in the order wrt any parameter
For eg:
select eid from event where creator=PAGE_ID and eid in (select eid from event_member where uid=PAGE_ID) ORDER BY start_time DESC
Upvotes: 1