Get Facebook user profile using their photo filename

If you find some image file saved from Facebook, you can quickly get the users profile ID and other details from the image file name. Every image saved from a Facebook profile has a unique filename such as ‘86948_8239343856_5678_n.jpg’ (this is a dummy number).

The 2nd number from left in the filename, in this case 8239343856, which is the unique profile ID of the Facebook user.

So now the Facebook profile URL for the user is http://www.facebook.com/profile.php?id=8239343856. The following PHP script will help you get the various details like name, username, gender and locale.

<?php
 
/* filename like 86948_8239343856_5678_n.jpg */
$photo_name = "PHOTO_FILENAME";
 
$profileId = explode("_", $photo_name);
 
/* filename format */
switch(count($profileId)) {
    case 6 :    $id = $profileId[2];
                break;
    case 4 :    $id = $profileId[1];
                break;
    case 3 :    $temp = array("n", "N");
                $id = str_replace($temp, "", $profileId[0]);
                break;
    default:    break;
}
 
$profileLink = "http://www.facebook.com/profile.php?id=".$id;
$profileImage = "http://graph.facebook.com/".$id."/picture?type=large";
$graphAPI = file_get_contents("http://graph.facebook.com/".$id);
$graphJSON = json_decode($graphAPI, true);
 
print_r($graphJSON);
 
?>

10 Responses

  1. Rakib tem says:

    You did such a great job! Thankz !

  2. Just says:

    Doesn’t work.. :(

  3. russianspy1234 says:

    It used to, seems not to anymore, they probably caught on. Maybe facebook cares about privacy after all?

  4. Jim says:

    This was changed a while ago! i found a new solution here http://fileperms.org/facebook-changes-photo-filename-pattern/

  5. Bob Marcus says:

    Work for me just fine.
    But only on a profile pictures, not on any picture name with numbers.

    I found a solution on the net ………. :)

    You can download chrome extension that do the same job:
    http://www.auserfinder.com

    Now you can easily do that.
    cheers

  6. leo says:

    it was nice tutorial. but in my case I dont have picture file name in that format. The format i have is IMG_25302073190279.jpg.
    how to trace this FB user? I have 100% sure it is from FB.
    Please send me the detail in my email or send me the profile of that picture in email. I want to know who is he.

  7. mofker says:

    Works fine if you have older photos with the ID in them, newer photos have different numbers.

  8. Rahul says:

    Thanks working for me

  9. praveen says:

    It is not working.it is coming it is temporarily unavailable.and try aftersometimes

  10. This does still work, but only seems to work for those images that are shared to public.

    http://www.facebookcreep.com lets you enter the code and see if it can locate the origin.