I am working with php, and trying to call a function within a block of code, but I do not know why it causing the error that Uncaught Error: Call to undefined function GetUserIDFromUsername(), while it is defined later then.
The PHP Code
if(isset($_GET["updateRow"])){
$_fbURL = $_GET["ajaxified"];
if(!empty($_fbURL)){
$url = $_fbURL;
$urlParts = explode("facebook.com/", $url);
$username = GetUserIDFromUsername($urlParts[1]);
function GetUserIDFromUsername($username) {
// For some reason, changing the user agent does expose the user's UID
$options = array('http' => array('user_agent' => 'some_obscure_browser'));
$context = stream_context_create($options);
$fbsite = file_get_contents('https://www.facebook.com/' . $username, false, $context);
// ID is exposed in some piece of JS code, so we'll just extract it
$fbIDPattern = '/\"entity_id\":\"(\d+)\"/';
if (!preg_match($fbIDPattern, $fbsite, $matches)) {
throw new Exception('Unofficial API is broken or user not found');
}
return $matches[1];
}
echo "My Id is : "." ".$username;
}
}