Facebook API : How to display user's name whitout auth? - facebook

My question is very simple
On this page: http://www.facebook.com/axefan?sk=app_116526158422952
How did they do to show the names of the connected user, without asking permission? I thought it was not possible to have UID of a member without going through auth?

You don't need an access token to get the name of something in Facebook. You just need the id of whatever it is you are checking (Person, page, event, etc).
For example, you can check these without appending any access token to the URL:
http://graph.facebook.com/595869823?fields=id,name
http://graph.facebook.com/292378408255?fields=id,name

Related

FB LOG IN RESTRICTIONS, allow only specific users to log in on your site using fb login

I am trying to make a website where only specific users can log in, and I was hoping to use FB LOG IN for this purpose,
is there a way to make only allowed users to log in using FB LOGIN SDK,
I already tried by using userID, but seems the userID I am getting is different from what I can get from their profile,
using their name isn't also reliable as anyone can create a dummy account with the same name,
I cannot get their username showing on facebook.com/"username"
are there ways to get that or any other way to restrict the log in button
You will only get an "App Scoped ID", and you will only get it after login. One way is to disallow access by default and activate access for specific users after they authorized your App.
You can also ask for the email, btw.

Get Facebook profile URL from app-scoped user ID

A Facebook user's profile URL is http://facebook.com/USER_ID. However, with an app-scoped user ID, http://facebook.com/APP_SCOPED_USER_ID doesn't redirect to the user's profile page. How can I reach an user's profile page using just an app-scoped user ID?
Use the link field of the user object. This will look like the following:
https://www.facebook.com/app_scoped_user_id/{app_scoped_user_id}/
The URL - https://www.facebook.com/app_scoped_user_id/{app_scoped_user_id}/ - is access limited, only X request can be made on Y period of time from an account.
I did build a tool to crawl facebook's username base on app-scoped uid, by making a request to that scoped uid profile, I can parse the redirect header to find out the username.
The access limitation makes me suck. :(
You can use url format:
http://fb.com/app_scoped_user_id/{app_scoped_user_id}
example
http://fb.com/app_scoped_user_id/10101640953722381
If you want to get real facebook id from app scoped user id: https://stackoverflow.com/a/34450491/2181069
Tested that the above answer: https://www.facebook.com/app_scoped_user_id/{app_scoped_user_id}/ works for new user that connect to your app after migration.
As stated in FB documentation, existing connected users will continue to return the global ID. And it seems that https://www.facebook.com/app_scoped_user_id/{existing_user_global_id}/ won't work.
Thus, need to differentiate between existing and new user and use the global url (https://www.facebook.com/{user_global_id}) and app-scoped URL accordingly. Kind of tedious...

How to get a facebook user id from the login email address

Is there a way to get a user's facebook user id from their login email address?
I want an API call where I can provide joe#example.com and get facebook user id 342255534.
I'll use that id to call http://graph.facebook.com/342255534/picture?type=large
The closest thing I've found is https://graph.facebook.com/search?q=EMAILADDRESS&type=user&access_token=ACCESSTOKEN, but that requires an access token, which I'm hoping to avoid.
I know this isn't how it's supposed to work, but is there a way to get a generic access token?
You can use your own access_token for the application, and change it to a long-lived access token so you can make the API call in a cron. The only issue is that you will have to login to the app every so often to update the access token.
UPDATE: The User Search API is now deprecated, so you cannot search using email addresses. But name based searches still work.
You can create an app and get an access token for that app. Instructions are here: https://developers.facebook.com/docs/authentication/applications/
Unfortunately, a search for a user_id by email only works with a user access token.
You don't need to be friends with a user to get their id by email address.

Facebook API - Search for users by name without access token

I need to search for certain users on Facebook by their names(ex. Full name or First_name). Is it possible to do that without having access token for user?
No, you cant do that,
Atmost, you can search for User object (note, that you MUST provide search type) (will include everything related with jashwant)
http://graph.facebook.com/search?q=jashwant
but this
http://graph.facebook.com/search?q=jashwant&type=user
append access_token to requested URL.

Retrieve User ID before application permissions

Is it possible to retrieve an user id before agreeing to give permissions to an application?
I'm trying to salute a user before agreeing to the permission request. But for that I'll need to know his/her user id so I can access the info via graph API.
The idea is to do it when he/she is visiting for the first time my page app.
http://apps.facebook.com/xxxxxxxxxxxxxxx
Any idea?
This is NOT possible. Facebook WILL NOT share the user id with any app without the user explicitly allow that (partners are always a special case).
No it is not possible.
The only way to get the details of the current user is to issue a request to
https://graph.facebook.com/me?access_token=ACCESS_TOKEN
But here the problem is to get the access token, user should allow the application first.