using the facebook graph to display profile pictures ...what if someone changes their username? - facebook

I am building a web app that will retrieve basic Facebook user information, among them also the profile photo, via
https://graph.facebook.com/USERNAME/picture?width=100&height=100
I plan on storing that variable in my database so that I can display the profile photos in the web app.
Now, I'm wondering what happens when someone changes their Facebook username from "jimmysmith" to "jamesdoe", for example? I assume that my saved URL of
https://graph.facebook.com/JIMMYSMITH/picture?width=100&height=100
will stop working? Is there any way around this?
Or will it still work because Facebook redirects the old username to the new username, maybe? I found no evidence of that, however. I have no way of testing it, either.
The way I retrieve it via FQL is:
$fql = "select uid, name, email, birthday from user wher.... etc.

Use the user IDs instead.
Usernames will not be query-able in v2.0 API.
See https://developers.facebook.com/docs/apps/upgrading for more information.

Related

How do I manage a users facebook "managed pages"?

I am currently working on a project where we want to post to a users facebook wall or the wall of one of a users managed pages.
See this page: https://socialiteproviders.github.io/
Note that facebook is not listed! Weird being it is one of the top social networks, why is it left to be a custom, override provider?
return Socialite::with('facebook')->scopes(['publish_actions', 'manage_pages', 'pages_show_list'])->redirect();
and then
$user = Socialite::driver('facebook')->user();
Where can I find documentation on socialite in regards to facebook? Specifically how do you get the information on managed pages for the user who just logged in.
We do have app permission from facebook. When you link your account, on the facebook page it pops up asking to give permission to the app to manage pages.
When I dd() the results of ->user()
I get
token, refreshToken, expiresIn, id, nickname, name, email, avatar, user -> [name, email, gender, verified, link, id], avatar_original, profileUrl.
If I understand correctly, there should be a way to get a "data" attribute that contains information on managed pages.
see this link: https://developers.facebook.com/docs/pages/access-tokens#multiple-pages
Am I going to have to work directly with the Facebook API, or is there a way to get this information out of socialite?
Thanks!
EDIT:
I was asking additionally about a facebook provider, and whether it was hard coded into socialite. I have since posting this foind in vendor/laravel/socialite/SocialliteServiceProvider.php is actually wired up for facebook. I still however, cannot figure out how to manage a facebook users "managed pages"
You are close, in my opinion.
As you can see in the Facebook API Documentation, to give your application the ability to publish in a page that the user manages, you need to ask for manage_pages y publish_pages permissions.
On the other hand, by default Socialite will ask Facebook for the most common fields (like id, email, name, etc) but to get extra -driver specific- fields you need to specify them too. So this should do it:
return Socialite::
with('facebook')
->scopes(['manage_pages', 'publish_pages', 'the_rest_of_your_scopes'])
->redirect();
And to retrieve the user:
$social_user = Socialite::
driver('facebook')
->fields(['accounts', 'some_other_extra_fields'])
->user();
Disclaimer: I haven't test it yet, but this should include an accounts key in the user object that will have an array of the user page(s), his/her role(s), page info and the token to perform actions in the page (yes, like publish).
I hope this can serve you as a guide at least. Good luck.
If you check the following Official Laravel Socialite Pacakge
(Use this Package )
https://github.com/laravel/socialite
Facebook providers are there already.
Get the access token from Facebook
Save it to database
Use the graph API of facebook to access page details.
Send the saved access token with api requests
Alternatively you can use this package too.
https://github.com/SammyK/LaravelFacebookSdk

Search the Facebook UserName in Unity

I'm making a game where I can link the user account with Facebook. So far so good, but I need a value that identifies the Facebook user, as the name, but that is unique. So I thought of user name that is unique per account. But I found no information in the Facebook documents that show how to get this information. Does anyone know how I can get this? And it is not the name that the user puts in his profile, it is the username.
The best way to do this (and the best way to store) is by the use of User IDs. Facebook allows you to do this.
User: https://developers.facebook.com/docs/graph-api/reference/user/
I personally don't use Facebook API but from experience you would use an User ID.

Facebook api: get users by work

Is it possible to get all Facebook users by work ID? I tried to find it via google but I'm getting the results I need.
I have the 'work ID' (which is infact a page, right?), but now I need all users that work there..
No, there isn't a way to get all users by work directly from FB. You can query the user table to get a particular user's work history but the converse isn't possible. Perhaps LinkedIn offers that kind of data ? But Facebook doesn't AFAIK.

Get users Facebook ID for database

I need the following, any help would be much appreciated.
I Have a registration form.
It inputs the data Name | ID | DOB | TWITTER | FBID
When the user registers it asks for the above values.
Twitter is easy as users can just put in their Twitter ID.
But I Need to get the users Facebook ID in the form.
What would be the best way to do this?
Could i use the 'Connect To Facebook" Feature.
All i need is the Facebook user ID so that i can use it when retiring graph data later on.
I have set up a Facebook Application and am using PHP with a MySQL database.
Thanks
Alex
Well, they have specific APIs for different functions. In your case none of their simple solutions work. You will probably need to use Facebook's Graph API. You should take a look in their PHP SDK. It is a very useful tool. I used it once and it worked perfectly.
You will need to know much, before you get the users is. Also if you want to make that automatically, they will have to be logged in and they will have to confirm access to their personal data from your facebook app.
Good luck!
For any user data you wll need to get permission from user.
You can use Facebook connect.
Make the user log in and get access token, this access token is the key to all user data.
You can use this access token with graph API also.
Check my blog.

Facebook Connect: what type of user profile information can be retrieved?

When enabling Facebook Connect, any facebook user can then login to your website,
what type of user profile information can my website retrieve?
Username?
Email?
First Name?
Last Name?
There is a ton of information you can retrieve, if the user has permitted it through their privacy settings. Just about everything you can retrieve is in a FQL table somewhere:
http://wiki.developers.facebook.com/index.php/FQL_Tables
You cannot, however, get their email. You need to ask permission, using the API, to do that. This is also not a data bonanza, you can only permanently store the user ID. Everything else you can only store for 24 hours, then need to re-query Facebook for the information.
If you just want to display the user's first and last name, you can use FBML rendered with the Facebook Connect code.
http://wiki.developers.facebook.com/index.php/FBML
Khou,
There are seriously loads of API docs around.
Good luck on your facebook journey ;)