Facebook Graph Api 2.1 get userid from username

facebookfacebook-graph-apifacebook-graph-api-v2.0

I am looking for a solution which can provide me user id from profile url or fb username

example :http://facebook.com/username

get userid of this url

and also when I try to read friends (I have friend related permission), I am getting blank data array ex:

 graph api requ: https://graph.facebook.com/v2.1/me/friends?access_token=xxxxx
 response:
    {
      "data": [
      ], 
      "summary": {
        "total_count": 455
      }
    }

Please let me know how can I get friend list and userid using username in Facebook graph api v2.1

Best Answer

graph.facebook.com/username has stopped working. There is an unpleasant workaround. In my limited testing, this works in Chrome.

Wherever you see the facebook user name in a timeline entry, right click and select "inspect element." In the window that opens, scroll up a little and look for the string:

"data-hovercard="/ajax/hovercard/hovercard.php?id=".

The Facebook id of the username you right clicked on follows the = sign.

This only seems to work on names on the timeline.