Facebook ‘s API is every changing and is a mystery sometimes. Today when I was dealing with one of my client, his requirement was to get User ID (UID) of a user without having to ask for “Access permission” from the user. However, this is NOT possible. Facebook does not allow to grab UID, they treat the user id as a serious thing and do not share it like that. Apparently, some Facebook pages do show username of the logged in user, without having to ask for any sort of permission. Does not really matter if you do not like that page as well. Have a look at this demo page – http://www.facebook.com/digimantra?sk=app_256564141033045

This page contains the following code –

<html xmlns:fb="http://www.facebook.com/2008/fbml">
    <div id="fb-root"></div>
        window.fbAsyncInit = function() {
                appId: 'APP_ID',
                cookie: true,
                xfbml: true,
                oauth: true
        (function() {
            var e = document.createElement('script'); e.async = true;
            e.src = document.location.protocol +
        <script type="text/fbml">
            <div style="font-size:2em;" >
                Hello, <fb:userlink uid="loggedinuser"/>

The username is shown with the FBML tag <fb:userlink uid=”loggedinuser”/> . The rest of the script is included to make the FBML work. Hope now you can welcome your user with their name instead being treated as a stranger.

Hope this helps.

Stay Digified!!
Sachin Khosla

Share this post: