How to get users additional information using Laravel Facebook Socialite - facebook

I am trying to get the users additional information like gender, birthdate, email, and hometown. I am using this code below:
$user = Socialite::driver('facebook')->fields([
'first_name', 'last_name', 'email', 'gender', 'birthday', 'location'
])->scopes([
'email', 'user_birthday', 'location'
])->user();
But my problem for now is it is not getting the user location or hometown, sometimes, it also failed to fetch the users' gender and birthday. How can I access the users' data without using the App review in Facebook for developers.

https://developers.facebook.com/docs/facebook-login/permissions
The permissions would be user_hometown and user_location, according to the docs.
https://developers.facebook.com/docs/graph-api/reference/user
The fields would be hometown and location.

Related

Page Admin - Graph Api Comment as User

its a bit complicated because i dont understand might be a bug.
OR MAYBE i making a mistake.
User allows the Application and the same time user ist the Admin of the Fanpage.
I store all Data Accesstoken uid etc.. in the Database.
Now i want to post comments on a Photo as the user (The user is also Admin of the Fanpage)
The problem is that the comment is posted Successfully but the Comment is from Fanpage.
I just want to post as the user as he is.
Im using the Access Token of the User which i stored in the Database and also using Form fields with name & id.
Anybody out there facing the same problems ?
$details = array( 'message'=> $photodata,'access_token' => $tok, 'from' => $from);
$from = array( 'name'=> $nome,'id' => $ad);
$addscomment = $facebook->api("".$photoid."/comments", 'post', $details);

Web app is in Users Facebook Apps section as approved but Facebook not returning verified==true

I am using Facebook PHP SDK. There are some Facebook users that can't register or login with my site.
$user_profile = $this->api('/me');
Everything is working for most Facebook users joining the site. But I have just created two new Facebook accounts to test this due to a user complaint and both new facebook accounts are not returning the $user_profile['verified'] data.
I get:
array (size=11)
'id' => string '10000501019xxxx' (length=15)
'name' => string 'Toby xxxx' (length=12)
'first_name' => string 'Toby' (length=4)
'last_name' => string 'xxxx' (length=7)
'link' => string 'http://www.facebook.com/toby.xxxx.90' (length=39)
'username' => string 'toby.xxxx.90' (length=15)
'gender' => string 'male' (length=4)
'email' => string 'xxxx99#gmail.com' (length=22)
'timezone' => int -6
'locale' => string 'en_US' (length=5)
'updated_time' => string '2013-01-08T00:38:06+0000' (length
The web application is in the facebook users Account Settings > Apps and shows as approved.
Even though everything is working up to the point where the application is registered in the Facebook user's apps, Facebook still is not returning the $user_profile['verified'] == true therefore the user can't finish the registration.
I tried a work around where the after the user checks their Facebook profile to see if the App is there and approved they can still register. But, when trying to return and login, the $user_profile = $this->api('/me'); still doesn't contain the $user_profile['verified'] == true.
I really don't know how many users are running into this. But like I said two new test Facebook accounts that have the web app approved still don't register as having verified the app.
I don't know what else to do since I am receiving registrations and logins. The users that can't have the web App in their Facebook Aps section. Just seems like Facebook is not returning the verified=true for some reason.
Any ideas?
I took out the test of if the user had verified the account and, of course, the user can register and login. I deleted the app from the user's Facebook account then went back to the app to login. Facebook dialog then requires the user to re-approve the app. Strange that some users' data will not return that they have verified the app.
Strange that some users' data will not return that they have verified the app.
I think you might have misunderstood the meaning of the verified field here.
This has nothing to do with the user authorizing your specific app!
Instead it means whether the user has verified their account with Facebook, i.e. confirmed their identity by mobile phone, credit card or some other means.

How get public information of a user in facebook without requesting for his/her permission?

Is there a way to get public information of a user without requesting for his/her permission? In facebook I know that we can get the basic informations of the user such as id, name, picture, gender, and his locale (but not his other public information) without requesting for his permission. Look at this link: http://zesty.ca/facebook/
I examine the source code and found out that he gets the access token. How does this link do that. How did he get the access token and get the public information of the user?
You can query the public data with just the app token that your Facebook app has after initialization to access contents like :-
id
name
first_name
middle_name
last_name
gender
locale
Others listed here with either no access token or app access token
To do so, after initializing your Facebook application like
$facebook = new Facebook(array(
'appId' => 'APP-ID',
'secret' => 'APP-SECRET',
));
You can query Graph api simply as
$user_public_profile = $facebook->api('/user','GET');
And retrieve the data.

Birthday field not returning data

Basically I got 2 question here:
once the user given permission to a facebook application at fbconnect, is it anytime the application can post the fb user's wall?
How about later when they logout from facebook already?
Does application owner still have the permission to like post to their wall? Or need to wait till they login to facebook connect the second time only can re-access the information?
Somehow the birthday field for all my friends are returning as empty.
I am using latest php sdk from github.
$friends = $facebook->api('/me/friends');
$_SESSION['fb_user_friends'] = $friends;
foreach ($friends as $key=>$value)
{
echo '<br>';
foreach ($value as $fkey=>$fvalue)
{
//all the query return values, except birthday and birthday_date field
//birthday and birthday_date field totally don't have any friend's DOB appearing, all empty.
//wonder why
$fql = "SELECT uid, first_name, last_name, name, birthday, birthday_date FROM user WHERE uid=".$fvalue[id];
$param = array(
'method' => 'fql.query',
'query' => $fql,
'callback' => ''
);
$userDetails = $facebook->api($param);
print_r($userDetails);
}
}
EDIT: this is no longer an accurate answer
-It can post on the wall if you asked for that permission.
'req_perms' => 'publish_stream,...
To post on wall of loged out user you need another permission "offline_access". All permissions: http://developers.facebook.com/docs/authentication/permissions
-Birthday. I experienced the same. Birthday sometimes empty because user didn't provided it or set the security high and apps can't ask for it. And you have to ask for 'friends_birthday' permission too at registering to your app.
in 'settings' on your application, go to 'permissions' and enable 'User & Friend Permissions': 'user_birthday', 'friends_birthday'

Posting to Friends Wall

In the new PHP SDK is there any way to post to a friends wall?
I have seen several apps do it. Like apps that say "your friend asked you a question", and I'm not even a user of that app. Is there any way to do it?
I am using an FBML canvas. I already have all the users friends, just need to figure out how to post to the friends they select from the list.
Thanks
You can use the facebook api method below, this works with the 3.1.1 SDK:
$publishStream = $facebook->api("/$user/feed", 'post', array(
'message' => "Your Message",
'link' => 'http://example.com',
'picture' => '',
'name' => 'App Name',
'description'=> 'App description'
));
Just replace the $user variable with the user id of your friend.
Yes, as long as you have the publish_stream extended permission
Enables your application to post
content, comments, and likes to a
user's stream and to the streams of
the user's friends, without
prompting the user each time.
As far as publishing goes
http://developers.facebook.com/docs/api#publishing