Search code examples
c#facebookurlconvertersuserid

How to get facebook user name In URL by using facebook id?


when I enter url with an user id(1111111111) https://www.facebook.com/1111111111 the browser redirected to https://www.facebook.com/kamal.a.ewee. kamal.a.ewee is the user name appear in the url represented by the user id. If I have user id how to convert it in the user name like kamal.a.ewee ?


Solution

  • This code:

    identifier = url.substring(url.lastIndexOf("/"))
    graphUrl = "https://graph.facebook.com/" + identifier
    urlJsonData = getGraphData(graphUrl)
    

    Should work the same (that is result with the same data) for both:

    url = http://www.facebook.com/southpark
    

    And

    url = http://www.facebook.com/6708787004
    

    (you'll obviously need to implement the getGraphData method).

    Also, the 2nd url form in the question is not a valid url for pages, at least not from my tests, I get:

    You may have clicked an expired link or mistyped the address. Some web addresses are case sensitive.