0
私はPHPで作業しており、コードのブロック内で関数を呼び出そうとしていますが、なぜそれがエラーの原因であるのかわからないUncaught Error: Call to undefined function GetUserIDFromUsername()
、致命的なエラー:未定義の関数、PHPを呼び出す
PHPコード
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;
}
}
** URL **から正確なデータを解析していますか?応答については必ず確認してください。 –
私は同じコードをちょうどissetメソッドを削除しようとすると、それは必要なデータを返します、あなたはfacebookのURLを提供する簡単なPHPでそれを試すことができます – Nadeem