Reputation: 1068
I want to get the only fb username how it is? This is my code
$user = $this->facebook->user();
$fbfriends = $this->facebook->call('get', 'me/friends');
$friends=$fbfriends->data;
here it returns the name and id.But the name is not username.is there any solution to get the username only from the above function using?
Upvotes: 0
Views: 1946
Reputation: 195
For getting your username
http://graph.facebook.com/id?fields=username
and for friends usernames
http://graph.facebook.com/id/friends?fields=username&access_token=XXXXXXXXXXXXXXXXXXXX
For more information Facebook Graph Api Fields Expansion
Upvotes: 0
Reputation: 5196
try this
https://graph.facebook.com/id
you will get a json result, including name
Upvotes: 0
Reputation: 5736
Try this:
$user = $this->facebook->user();
$fbfriends = $this->facebook->call('get', 'me/friends?fields=id,username,name');
$friends=$fbfriends->data;
This will fetch the username
, id
and the name
of the user.
Upvotes: 2