我只在移动设备上收到此错误。登录重定向正常工作,用户被正确重定向回应用程序。我没有错误。然后,如果我第二次访问该应用程序(第一次使用后的几秒钟)file_get_contents 会抛出一个 400 错误请求 - 这是代码 - 非常感谢帮助:-)
$code = $_REQUEST["code"]; 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;