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 thoughts on “Get Facebook user profile using their photo filename

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

  2. 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

  3. 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.

Comments are closed.