So far I can get information about the user's hometown:
$userProfile = $this->_facebookRequest->getGraphObject(GraphUser::className());
Then I can extract out the page for their hometown (hometowns do not seem to be castable to GraphLocation):
$homeTownPageId = $userProfile->getProperty('hometown')->getProperty('id');
Then I can get that page:
$pageRequest = (new FacebookRequest($this->_facebookSession, 'GET', '/' . $homeTownPageId ))->execute();
Then I'm stuck. If you actually go to a location page, they look like this . Over on the top right you can see it clearly says 'United States'.
How can I extract out that information using the facebook SDK? I have tried casting the page to a GraphLocation
and using getCountry
but it doesn't work.
When you construct the login button (for example with <fb:login-button>) you must determine in "scope" attribute which fields do you plan to read. Some fields are public, some not.
For example if you want to rearch the hometown field you must use facebook button like here:
<fb:login-button autologoutlink="true" scope ="public_profile,email, user_hometown "></fb:login-button>
Parameters (permissions) used in " scope " are these:
PERMISSIONS : public_profile (Default), user_friends, email, user_about_me, user_actions.books, user_actions.fitness, user_actions.music, user_actions.news, user_actions.video, user_actions:{app_namespace}, user_activities, user_birthday, user_education_history, user_events, user_games_activity, user_groups, user_hometown, user_interests, user_likes, user_location, user_photos, user_relationships, user_relationship_details, user_religion_politics, user_status, user_tagged_places, user_videos, user_website
EXTENDED PERMISSIONS : read_friendlists, read_insights, read_mailbox, read_page_mailboxes, read_stream, manage_notifications, manage_pages, publish_actions, rsvp_event
See documentation: https://developers.facebook.com/docs/facebook-login/permissions/v2.2
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.