Я запускаю приложение в Facebook, и у меня возникают проблемы с получением информации о пользователе.
Информация, которую я не могу получить, следующая:
hometown_location
current_location
work
Вот мой код:
<?php
$app_id = "";
$app_secret = "";
$my_url = "";
session_start();
$code = $_REQUEST["code"];
if(empty($code)) {
$_SESSION['state'] = md5(uniqid(rand(), TRUE)); //CSRF protection
$dialog_url = "https://www.facebook.com/dialog/oauth?client_id="
. $app_id . "&redirect_uri=" . urlencode($my_url) . "&scope=email,offline_access,publish_stream,user_birthday,user_education_history,user_location,user_hometown,user_relationships,user_relationship_details,user_work_history&state="
. $_SESSION['state'];
echo("<script> top.location.href='" . $dialog_url . "'</script>");
}
if($_REQUEST['state'] == $_SESSION['state']) {
$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));
echo("Hello " . $user->name.'<br />');
echo("id " . $user->id.'<br />');
echo("mail " . $user->email.'<br />');
echo("birthday " . $user->birthday.'<br />');
echo("sex " . $user->sex.'<br />');
echo("hometown_location " . $user->hometown_location.'<br />');
echo("relationship_status " . $user->relationship_status.'<br />');
echo("current_location " . $user->current_location.'<br />');
echo("education " . $user->education.'<br />');
echo("work " . $user->work.'<br />');
}
else {
}
?>
Я получил секс с "полом", но не могу понять других.