Posted By

federicoq on 02/07/13


Tagged


Versions (?)

Geotag


 / Published in: jQuery
 

geotag

  1. <?php
  2.  
  3. isGyu();
  4. MethodAjax();
  5.  
  6. $url = 'http://maps.googleapis.com/maps/api/geocode/json?origin=roma&address='.urlencode($_POST["where"]).'&sensor=false&region=IT&locale=IT';
  7.  
  8. // disguises the curl using fake headers and a fake user agent.
  9. function disguise_curl($url)
  10. {
  11. $curl = curl_init();
  12.  
  13. // Setup headers - I used the same headers from Firefox version 2.0.0.6
  14. // below was split up because php.net said the line was too long. :/
  15. $header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,";
  16. $header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
  17. $header[] = "Cache-Control: max-age=0";
  18. $header[] = "Connection: keep-alive";
  19. $header[] = "Keep-Alive: 300";
  20. $header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
  21. $header[] = "Accept-Language: it-it,it;q=0.5";
  22. $header[] = "Pragma: "; // browsers keep this blank.
  23.  
  24. curl_setopt($curl, CURLOPT_URL, $url);
  25. curl_setopt($curl, CURLOPT_USERAGENT, 'Googlebot/2.1 (+http://www.google.com/bot.html)');
  26. curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
  27. curl_setopt($curl, CURLOPT_REFERER, 'http://www.google.com');
  28. curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate');
  29. curl_setopt($curl, CURLOPT_AUTOREFERER, true);
  30. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  31. curl_setopt($curl, CURLOPT_TIMEOUT, 10);
  32.  
  33. $html = curl_exec($curl); // execute the curl command
  34. curl_close($curl); // close the connection
  35.  
  36. return $html; // and finally, return $html
  37. }
  38.  
  39. $url =
  40. $file = disguise_curl($url);
  41. echo $file;
  42.  
  43. ?>

Report this snippet  

You need to login to post a comment.