Facebook Get User ID From Application Tab - facebook

Facebook apps are allowed to have a tab that a user can add to his profile's tabs if he wants.
How can I get the uid or otherwise identify the currently logged in user in order to customize the layout for him please?
Thank you.

As noted here:
Facebook does not pass back who the viewing user is when she first visits your tab. Facebook does send the profile owner's ID in the fb_sig_profile_user parameter, so you know whose profile to display content for.
Visitor id is passed as request parameter after a user interacts with your tab. I can't find exact parameter name as they removed a wiki page that used to contain a list of all passed parameters, but if you dump all your request vars you should be able to see it (but not during the first visit).

some sources to do it + you must have turned on all items on migration in app settings
http://nathrondevblog.blogspot.com/2010/09/how-to-get-user-id-in-profile-tab.html

Try out this one,
If the user is logged in. You can directly get the user_id, session_key etc from the querystring.
long fbuid = long.Parse(Request.QueryString.Get("fb_sig_user"));

Related

Retrieve facebook id from profile image address

If I only have the facebook profile address (something like https://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn2/c0.0.180.180/1425794_10202604468931708_129792007_a.jpg ) , can I retrieve it's user ID? The aforementioned address is the only information known.
Thanks
Yes.
From the second set of numbers in the file name go to this URL http://facebook.com/10202604468931708
You will see that takes you to a page for that picture. On that page you can see the owner of the picture. Navigate to the profile.
From the profile, change www to graph In the URL.
The resulting page will show the Facebook id of the user.
The second set of numbers is indicative of the profile it originated from.
www.facebookcreep.com is a tool that takes this number and searches for the profile it came from.
Hope this helps people!

trying to get both the userID and the ID of the profile where the clicked on the app

I am designing an app that lets one facebook user commission another user. I'm new to the facebook API, but I'm doing my best - hopefully someone can point me in the right direction.
The app does the following:
1) Once authorized, it creates a tab on your timeline.
2) Then another facebook user clicks on this tab.
3) once they authorize and give permission, I want to capture the user id of the logged in user (this is easy) and the ID of the profile on which they clicked to install the app (this I can't do). I'm sending these off to a MySQL server.
So am I capturing two distinct userIDs? Or a userID and a pageID? any help very appreciated!
Well you simply can't add applications to a user's profile. So what you are seeing is a PAGE_ID (assuming you mean that the application was installed on a page's timeline), and a USER_ID.
You'll find all this information in the signed_request that is passed to the page. Once you have decoded this signed_request the page info is in the page parameter -
page - A JSON object containing the page id string, the liked boolean (set to true if the user has liked the page, false if not) and the admin boolean (set to true if the user is an admin of the page, false if they're not). This field is only present if your app is being loaded within a Page Tab.
And the user info is in the user parameter -
user - A JSON object containing the locale string, country string and the age object. See the Age Object table for actual min and max values.

How to find out which user clicked an image on my facebook website/application?

Say I have a facebook page/app that contains images of products that I sell. Is there a way that I can find out who the user details(facebook account) is when an image is clicked?
Assumption I am making:
You are using a custom page tab
The page tab is an iframe
You have GDPed the user when they clicked on the body of the tab
You now know the user in the app on the tab
All actions by the user contain the user ID (so you can customize the experience)
Then you're already done!
C # facebook
you can take it by IP from access log, or you have to aim all images to php file (to log user data) before showing image
From my knowledge, the user has to connect with your app first, before you can get his user id. After you have this piece of information, it's rather simple to log all his requests.
Assuming that clicking on a product image doesn't necessarily send the user to a new URL, but maybe shows a zoomed image or shows more information, you could use Javascript to send an Ajax request to your server containing information about the product and FB user id. The URL can look something like this:
http://example.com/log.php?uid=xxx&product_id=ppp
Then server-side you'll store the information in the database.

Get facebook logged in user's ID on ASP CLASSIC

in a facebook app iframe tab, Is it possible, i tried with the JS SDK but then the user needs to allow that.
how can i get only his user id with classic asp?
Your website can't get at the user's Facebook Id in any way unless the user allows it. Period. Thank God -- I mean Zuck.
In short, When facebook contact your canvas url for displaying your tab, it set POST data that contains a signed_request parameter which contains amongst other :
a user field : A JSON array containing the locale string, country string and the age object (containing the min and max numbers of the age range) for the current user.
So no user id !
If you want to know more about your user, you have to go through the auth/permissions process. After that, in subsequents displays of your canvas, the user_id and oauth_token (and others) fields will be added to the POST variables.
More at : http://developers.facebook.com/docs/guides/canvas/#auth
This is also true for the "full app" view now that they have harmonized full apps and tab apps. The only difference now is the width of the iframe (520px for tab, 760px for full)

api to get uid from profile URL on facebook

Is there a way (using API) to get users uid from the profile URL in facebook?
The REST api has been deprecated.
The proper way to do this is to pass the profile name to the graph api
see: Facebook ID from URL
You can call the graph directly as such:
https://graph.facebook.com/username where username is the username you want to lookup.
As of today(28th July 2015), I found a different way to find Facebook user's numeric id from profile url (or username).
As you all will be knowing the profile url syntax is https://www.facebook.com/[username]
So just browse to profile url, right click to view source and search for string "uid":. You will get numeric id next to it.
Use Users.getInfo, which returns an array of user info, such as first_name, last_name, and uid. Use this call to get user data that you intend to display to other users (of your application, for example). If you need some basic information about a user for analytics purposes, call users.getStandardInfo instead.