fbiCal("http://www.facebook.com/ical/u.php?uid=youruid&key=yourkey");//Get from "export events"
function fbiCal($url)
{
$iCalstring = curl_get_file_contents($url);
preg_match_all("#BEGIN:VEVENT(.*?)END:VEVENT#s",$iCalstring,$tit1es);
preg_match_all("#BEGIN:VEVENT(.*?)END:VEVENT#s",$iCalstring,$items);
$n=count($items[0]);
for($i=0;$i<$n;$i++)
{
$iCaltemp= $items[0][$i];
preg_match_all("#SUMMARY:(.*?)LOCATION#s",$iCaltemp,$titles);
$title[$i]= $titles[1][0];
preg_match_all("#DTSTART:(.*?)DTEND#s",$iCaltemp,$startdates);
$startdate[$i]= $startdates[1][0];
preg_match_all("#DESCRIPTION:(.*?)CLASS#s",$iCaltemp,$descriptions);
$description[$i]= $descriptions[1][0];
preg_match_all("#event.php?(.*?)DESC#s",$iCaltemp,$eids);
$eid[$i]= $eids[1][0];
}
for($i=0;$i<$n;$i++)
{
$stitles=$title[$i];
$stitles=str_replace(" $stitles=str_replace("]]>","",$stitles);
$datum=$startdate[$i];
$startyear=substr("$datum",0,4);
$startmo=substr("$datum",4,2);
$startday=substr("$datum",6,2);
$datum=$startyear . "-" . $startmo . "-" . $startday;
$datum=strtotime($datum);
$datum=date('D, M d, Y',$datum);
$desc=$description[$i];
$desc = ereg_replace("[\n\n]", "", $desc);
$desc = str_replace("\\n\\n", "
", $desc);
$desc=stripslashes($desc);
$desc = ereg_replace("[\r] ", "", $desc);
$link="http://facebook.com/event.php" . $eid[$i];
$desc.="<a href=".$link. ">Go to Event Page</a>";
if(!empty($title[$i])) echo " " .$datum."\t\t\t <h2><a href=".$link.">".$stitles."</a></h2><p>" . $desc ."</p>";
}
}
function curl_get_file_contents($url) {
$c=curl_init();
curl_setopt($c,CURLOPT_RETURNTRANSFER,1);
curl_setopt($c,CURLOPT_URL,$url);
$contents=curl_exec($c);
if($contents) return $contents;
else return false;
}
?>
Thursday, July 30, 2009
Facebook Event List
Displays your event list, using the iCal Export from Facebook (http://facebook.com/events.php)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment