Skip to content

Instantly share code, notes, and snippets.

@niklasvincent
Created August 18, 2011 11:50
Show Gist options
  • Save niklasvincent/1153917 to your computer and use it in GitHub Desktop.
Save niklasvincent/1153917 to your computer and use it in GitHub Desktop.
Get details about Facebook event
<?php
function is_facebook_event( $url )
{
return ( preg_match("/http:\/\/www\.facebook\.com\/event.php\?eid=[0-9]*\.*/", $url) == 1 );
}
function get_facebook_event ( $url )
{
$m = explode('=', $url);
$eid = preg_replace("/[^0-9]/", "", $m[1]);
$content = @file_get_contents('https://graph.facebook.com/' . $eid);
if ( empty($content) ) {
return false;
}
$event = @json_decode($content);
if ( $event == null ) {
return false;
}
return $event;
}
var_dump( get_facebook_event( 'http://www.facebook.com/event.php?eid=155728437821607&ref=mf' ) );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment