Don't like ads? PRO users don't see any ads ;-)
Guest

asdasd

By: a guest on Jun 11th, 2012  |  syntax: None  |  size: 1.76 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.  
  3. /************************************************************
  4. * gCode - May 2012
  5. * default facebook image scraper
  6. * Don't forget to hire me to code your stuff ;]
  7. ************************************************************/
  8.  
  9.  
  10. // term used to get results..
  11. $keyword = 'jennifer';
  12.  
  13. // you need to set your access token
  14. $access_token = '';
  15.  
  16. // facebook gives you different size options for profile images
  17. $sizes = array('small','medium', 'large');
  18.  
  19. // number of results to grab.. max is 5000
  20. $limit = 5000;
  21.  
  22. // facebook graph url
  23. $url = 'https://graph.facebook.com/search?q='.$keyword.'&type=user&limit='.$limit.'&access_token='.$access_token;
  24.  
  25.  
  26. // grab initial results using curl
  27. $data = curly($url);
  28.  
  29. // decode dataz
  30. $results = json_decode($data);
  31.  
  32. print "[!] Found ".count($results->data)." results...\n";
  33.  
  34. // loop thru results
  35. foreach($results->data as $user){
  36.  
  37.   // grab image data
  38.   $image_data = curly('http://graph.facebook.com/'.$user->id.'/picture&type='.$sizes[2]);
  39.  
  40.   print "[!] Saving image data for id: ".$user->id."\n";
  41.  
  42.   // write image data to file named KEYWORD-USERID.jpg
  43.   file_put_contents($keyword .'-'.$user->id.'.jpg',$image_data);
  44.  
  45. }
  46.  
  47.  
  48. function curly($url) {
  49.  
  50.   // initialize
  51.   $ch=curl_init();
  52.  
  53.   // set curl options
  54.   CURL_SETOPT($ch,CURLOPT_URL,$url);
  55.   CURL_SETOPT($ch,CURLOPT_RETURNTRANSFER,1);
  56.   CURL_SETOPT($ch,CURLOPT_FOLLOWLOCATION,1);
  57.   curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,0);
  58.   curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,0);
  59.  
  60.   // execute
  61.   $data = curl_exec($ch);
  62.  
  63.   // check for HTTP request errors
  64.   if(curl_error($ch)) {
  65.  
  66.         print "[X] http error: ".curl_error($ch)." - ". curl_errno($ch)."\n";
  67.  
  68.   } else {
  69.  
  70.         // return the data if there are no errors
  71.         return $data;
  72.   }
  73.  
  74. }
  75.  
  76. ?>