2014-10-07 53 views
0

我有一個工作的PHP腳本女巫顯示來自Facebook頁面的事件。問題是隻顯示最後一個添加事件。這個事件還沒有開始。過去的所有其他事件都沒有顯示出來。任何想法爲什麼?我想顯示所有事件,包括過去的事件。Facebook的PHP顯示事件

<?php 

require 'facebook-api/src/facebook.php'; 
date_default_timezone_set('Europe/Amsterdam'); 
$facebook = new Facebook(array(
    'appId' => '*APP-ID*', 
    'secret' => '*SECRET-KEY*', 
    'cookie' => true, // enable optional cookie support 
)); 

try{ 
    $events=$facebook->api('/*PAGE-ID*/events?access_token=*ACCES-TOKEN*'); 
}catch (FacebookApiException $e){ 
    error_log($e); 
} 

foreach ($events["data"] as $event){ 

    $startTime=strtotime($event["start_time"]); 

      try{ 

      $ev=$facebook->api('/'.$event["id"]); 
       }catch (FacebookApiException $e){ 

       error_log($e); 
        } 


    ?>  


    <h2 class="head2"><?php echo $event['name']; ?></h2> 
    <img src="https://graph.facebook.com/<?php echo $event["id"]; ?>/picture?type=large" width="300"> 
    <p><b>Description:</b> <br><?php echo substr($ev["description"] ,0,250);?></p><br> 
    <b>When:</b> <br><?php echo date("l jS \of F Y",strtotime($event["start_time"])); ?><br><br> 
    <b>Time:</b> <br><?php echo date("h:i A",strtotime($event["start_time"])); ?>&nbsp;-&nbsp;<?php echo date("h:i A",strtotime($event["end_time"])); ?><br><br>     

       <?php 
      } 
      ?> 

回答