
asdasd
By: a guest on
Jun 11th, 2012 | syntax:
None | size: 1.76 KB | hits: 14 | expires: Never
<?php
/************************************************************
* gCode - May 2012
* default facebook image scraper
* Don't forget to hire me to code your stuff ;]
************************************************************/
// term used to get results..
$keyword = 'jennifer';
// you need to set your access token
$access_token = '';
// facebook gives you different size options for profile images
$sizes = array('small','medium', 'large');
// number of results to grab.. max is 5000
$limit = 5000;
// facebook graph url
$url = 'https://graph.facebook.com/search?q='.$keyword.'&type=user&limit='.$limit.'&access_token='.$access_token;
// grab initial results using curl
$data = curly($url);
// decode dataz
$results = json_decode($data);
print "[!] Found ".count($results->data)." results...\n";
// loop thru results
foreach($results->data as $user){
// grab image data
$image_data = curly('http://graph.facebook.com/'.$user->id.'/picture&type='.$sizes[2]);
print "[!] Saving image data for id: ".$user->id."\n";
// write image data to file named KEYWORD-USERID.jpg
file_put_contents($keyword .'-'.$user->id.'.jpg',$image_data);
}
function curly($url) {
// initialize
$ch=curl_init();
// set curl options
CURL_SETOPT($ch,CURLOPT_URL,$url);
CURL_SETOPT($ch,CURLOPT_RETURNTRANSFER,1);
CURL_SETOPT($ch,CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,0);
// execute
$data = curl_exec($ch);
// check for HTTP request errors
if(curl_error($ch)) {
print "[X] http error: ".curl_error($ch)." - ". curl_errno($ch)."\n";
} else {
// return the data if there are no errors
return $data;
}
}
?>