2011-08-26 63 views

回答

5

搜索返回搜索中返回的所有事件的ID。使用https://graph.facebook.com/search?q=party&type=event&until=today&fields=id您可以將ID結果循環到https://graph.facebook.com/eventid?access_token=yourapptoken以獲取包含描述,名稱,圖像等的事件數組;

爲頁&直播樣本事件搜索這裏:http://shawnsspace.com/plugins/plugins.searcher.php

參考:http://developers.facebook.com/docs/reference/api/event/

示例代碼:假定PHP-SDK 3.1.1安裝頁面上。

活動https://graph.facebook.com/search?q=conference&type=event


<?php 
    $qi = urlencode($_GET['qs']); 
     if(!$_GET['qs']){ 
     $qi = urlencode($_POST['qs']); 
      if(!$_POST['qs']){ 
     $qi = "party"; 
     } 
    } 
    $search = $facebook->api('/search?q='.$qi.'&type=event&limit=10'); 
     foreach ($search as $key=>$value) { 
     $i=1; 
      foreach ($value as $fkey=>$fvalue) { 
      $i++; 
      if($fvalue[id]=="h"){ 
      }else{    
      $id = $fvalue[id]; 
    $searchResp = $facebook->api('/'.$id.''); 
      $name = $searchResp[name]; 
      $location = $searchResp[location]; 
      $desc = $searchResp[description]; 
      $sTime = $searchResp[start_time]; 
      $eTime = $searchResp[end_time]; 

       echo $name. '<br />'; 
       echo $location. '<br />'; 
       echo $sTime. '<br />'; 
       echo $eTime. '<br /><hr />'; 
     } 
     }; 
    }; 
?> 
<form id="getsearch" method="post" action="yourpage.php"> 
<input type="text" value="" name="qs" id="searchbox" onclick="this.value='';" style="padding: 2px;" size="48"> 
<input type="submit" value="Search" style="padding: 3px;"> 
</form> 

+1

它的好,看你SO肖恩。 Facebook真的很棒,所以用戶將會受益良多。 +1詳細解答 –

+0

謝謝!阿維斯,我也很高興見到你。 –

+0

「FQL在v2.1之後棄用」來源:https://developers.facebook.com/docs/apps/changelog – augusto

1

事件在圖形API搜索目前僅限於事件名接受搜索;我不相信有計劃在短期內改變這種情況,不幸的是,