Are the names of profiles on Facebook publicly accessible, as if I would NOT need to log into Facebook to access them?
I am intending to store a large amount of names as a small piece of a larger project. I feel as if scraping Facebook for names would be a relatively simple task using the Facebook Graph API, but I am a little confused.
I found another tutorial online at http://jilltxt.net/?p=2810 which described an easy way of finding any Facebook profile picture using one simple line:
https://graph.facebook.com/USER-ID/picture?type=large
This was very helpful because I am able to use a range of ID numbers and a small amount of PHP to gather large amounts of profile pictures as seen on my test page here: http://www.joshiefishbein.com/fi/photobook.php
But what I am unfamiliar with is how I go from collecting pictures to names in this one simple line. Is it possible? Is there another (better) way?
Here's the code I am working with. The range of ID's are just an example.
function gen_pix($min, $max, $quantity) {
$numbers = range($min, $max);
shuffle($numbers);
$x_arr = array_slice($numbers, 0, $quantity);
foreach ($x_arr as $key => $value) {
$username = "https://graph.facebook.com/" . $value . "/";
$json = json_decode(file_get_contents($username), true);
echo $json["name"];
}
}
$x = 337800042;
$y = 337800382;
$z = 1;
gen_pix($x,$y,$z);
I've gotten a little farther with this code, I can echo $username
and I get the URL that I am looking for (for example https://graph.facebook.com/337800382/
) but I do not get anything after that. json_decode
isn't working seemingly.