我正在尝试从 Facebook API 存储家乡和位置,但在从家乡和位置数组中提取数据时遇到问题。(我已经获得了令牌许可)
"hometown": {
"id": "210336945633449",
"name": "xxxx, yyyyy"
我正在使用以下代码
function getUserData() {
$fb_cookie = $this->getCookie();
if($fb_cookie) {
$url = 'https://graph.facebook.com/me?access_token='.$this->getAccessToken();
$data = json_decode($this->getDataFromUrl($url));
$fb['id'] = $data->id;
$fb['name'] = $data->name;
$fb['first_name'] = $data->first_name;
$fb['last_name'] = $data->last_name;
$fb['link'] = $data->link;
$fb['birthday'] = $data->birthday;
$fb['gender'] = $data->gender;
$fb['email'] = $data->email;
$fb['location'] = $data->location; // <-----
$fb['hometown'] = $data->hometown; // <-----
$fb['timezone'] = $data->timezone;
$fb['locale'] = $data->locale;
$fb['updated_time'] = $data->updated_time;
$fb['picture'] = 'http://graph.facebook.com/'.$data->id.'/picture';
//tokens
$fb['token'] = $fb_cookie['access_token'];
$fb['token_expires'] = $fb_cookie['expires'];
return $fb;
}
}
谁能帮我解决这个问题?
谢谢