このエラーはモバイル デバイスでのみ発生します。ログインへのリダイレクトは正しく機能し、ユーザーはアプリに正しくリダイレクトされます。エラーは発生しません。次に、アプリに 2 回目にアクセスすると (最初の使用から数秒後)、file_get_contents が 400 の不正な要求をスローします。コードは次のとおりです。
$code = $_REQUEST["コード"]; if(empty($code)) { $my_url = 'https://m.facebook.com/apps/'.$app_id.'/?sid='.$surveyid.'&country='.$country; $dialog_url = "https://www.facebook.com/dialog/oauth?client_id=" . $app_id . "&redirect_uri=" . urlencode($my_url) . "&scope=user_birthday";
echo("<script> top.location.href='" . $dialog_url . "'</script>");
exit();
}
$my_url = 'https://m.facebook.com/apps/'.$app_id.'/?sid='.$surveyid.'&country='.$country;
$token_url = "https://graph.facebook.com/oauth/access_token?"
. "client_id=" . $app_id . "&redirect_uri=" . urlencode($my_url)
. "&client_secret=" . $app_secret . "&code=" . $code;
$response = file_get_contents($token_url);
$params = null;
parse_str($response, $params);
$graph_url = "https://graph.facebook.com/me?access_token="
. $params['access_token'];
$user = json_decode(file_get_contents($graph_url));
$me['id']=$user->id;
$me['gender']=$user->gender;
$me['first_name']=$user->first_name;
$me['last_name']=$user->last_name;
$me['birhtday']=$user->birthday;