Created
August 18, 2011 11:50
-
-
Save niklasvincent/1153917 to your computer and use it in GitHub Desktop.
Get details about Facebook event
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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