Share Pastebin
Guest
Public paste!

Google Latitude PHP JSON script

By: a guest | Jun 15th, 2010 | Syntax: PHP | Size: 0.60 KB | Hits: 455 | Expires: Never
This paste has a previous version, view the difference. Copy text to clipboard
  1. <?php
  2. function getGLatitude()
  3. {
  4.         $url = "http://www.google.com/latitude/apps/badge/api?user=MY_USER_ID&type=json";
  5.         $ch = curl_init($url)
  6.  
  7.  
  8.         //return the transfer as a string
  9.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  10.  
  11.         // $output contains the output string
  12.         $output = curl_exec($ch);
  13.  
  14.         // close curl resource to free up system resources
  15.         curl_close($ch);    
  16.  
  17.          
  18.         $json = json_decode($output, true);
  19.         return '<a href="http://maps.google.com?q='.urlencode($json['features'][0]['properties']['reverseGeocode']).'">'.$json['features'][0]['properties']['reverseGeocode'].'</a>';
  20. }
  21. ?>