사용자의 위치를 디코딩하고 싶습니다. 한다고 가정Facebook 디코딩 Json
"id": "100000564553314",
"name": "Adi Mathur",
"location": {
"id": "106487939387579",
"name": "Gurgaon, Haryana"
}
내가 이름을 얻을 수있는 스크립트를 사용하고 있지만 위치는 나에게 오류
을주고있다배열로 입력 stdClass의 객체를 사용 할 수 없음
$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 $_SESSION['name']=$user->name; // WORKS
echo $_SESSION['fbid']=$user->id; // WORKS
echo $_SESSION['location']=$user->location[0]; // ERROR
echo $_SESSION['location']=$user->location->name; // ERROR