How to get FB images without using or access tokens:
I tried to get only images of several members, but I got stuck and then wrote this snippet and worked for me,
HTML tag
<img src="getFbImage.php?id=<fbid_of_the_person>&type=[small|large]" />
PHP code
<?php $remoteImage = !isset($_GET['id']) ? "../images/default.png" : getImg($_GET['id']); $imginfo = getimagesize($remoteImage); header("Content-type: ".$imginfo['mime']); readfile($remoteImage); function getImg($id){ $dom = new DOMDocument; $dom->loadHTML(getData($id)); $tags = $dom->getElementsByTagName('img'); $img = ''; foreach ($tags as $tag) { $img =$tag->getAttribute('src'); if($img=='') continue; else if(isset($_GET['type']) && $_GET['type']=='large') break; } //This iteration has a lot of images try your luck. return $img; } function getData($id){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,'https://www.facebook.com/photo.php?fbid='.$id); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 Firefox/39.0'); $data = curl_exec($ch); curl_close($ch); return $data; } ?>
I just had to use a 30x30 image, and I got what I wanted. Also check that you also get a large image.
Hooray! Joy
joyBlanks
source share