can't retrieve location from facebook users

Juakali92

Not sure if anyone else has expeienced a similiar issue when using the Facebook-PHP-SDK v5 . To retrieve user profile items such as name,first_name, last_name..etc. I have the following call.

public function getProfile(){

try {

    $profile_request = $this->fb->get('/me?fields=name,first_name,last_name,email,gender,relationship_status, birthday, location');
    $profile = $profile_request->getGraphNode()->asArray();
    return $profile;

} catch(Facebook\Exceptions\FacebookResponseException $e) {
    // When Graph returns an error
    echo 'Graph returned an error: ' . $e->getMessage();
    session_destroy();
    // redirecting user back to app login page
    header("Location: ./");
    exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
    // When validation fails or other local issues
    echo 'Facebook SDK returned an error: ' . $e->getMessage();
    exit;
}

this is being called in my index.php page as follows:

$profile = $fblink->getProfile();
print_r($profile);

Now the strange this is, all of the users data is being printed Except for the users location. I have checked my permission in my app and Users_location has been enabled. I'm not recieving an error of any kind so i can't seem to find a reason for why this isn't being returned.

If anyone knows an easy workaround to return locations, this would be of great help. Or if anyone could shed some light why locations aren't being returned, this would be equally as helpful. Thanks

David G

It may be that the user in your example has not set a location. Alternatively, does your app explicitly request privileges from the User to access location? If it does not, I believe facebook limits certain information that you can gather to avoid the privacy implications of such. As a result you'll need to set up an app on facebook, and then when a user goes to log in on your site, explicitly request access to certain information like location etc.

Here is a link to permissions you can request through the login feature: https://developers.facebook.com/docs/facebook-login/permissions how to request permissions: https://developers.facebook.com/docs/facebook-login/permissions/requesting-and-revoking

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Facebook API : Can't retrieve score

From Dev

Facebook Open Graph: Can't Download - Could not retrieve data from URL

From Dev

How can I retrieve values from the database from a specific users?

From Dev

Facebook PHP SDK - can't retrieve cover photo for event

From Dev

Can't retrieve friend's album in Android/Facebook

From Dev

Can't get location and email using Facebook API

From Dev

How can i get all users in a specific location in Facebook Graph API?

From Java

Can't retrieve any data from database

From Dev

Can't retrieve files from hadoop hdfs

From Dev

Can't properly retrieve objects from NSMutableArray

From Dev

Can't retrieve $_POST value from URL

From Dev

Can't retrieve AJAX data from PHP

From Dev

Can´t retrieve the date from MySQL

From Dev

Can't retrieve value from session

From Dev

Can't retrieve from double HashMap

From Dev

Can't retrieve data in table from json

From Dev

can't retrieve value from JSON results

From Dev

CloudKit - Can't retrieve the data from iCloud

From Dev

Can't retrieve text value from QLineEdit

From Dev

Can't retrieve data from SharedPreferences?

From Dev

Can't retrieve values from a ManyToManyField in Django

From Dev

Can't retrieve data from controller AngularJS

From Dev

Unable to retrieve users facebook profile with android

From Dev

Can't remove users from specific role

From Dev

Can't remove users from specific role

From Dev

Can't get location from Android

From Dev

Unable to retrieve users from Quickblox

From Dev

Retrieve gps location from timezone

From Dev

Can't fetch data from Facebook SDK