Hi, I to was playing with the Google Latitude Badge API.
For some reason jQuery doesnt like it, so what i did was compare what Google returns to what the Flickr example does http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=json&jsoncallback=? The flickr one is wrapped in brackets ( ), it appears you need these when using the $.getJSON function. This does not fix it yet, the format was pretty dodgy, so what i did was call my own script (with the user ids i wanted ?user=<ids>) and the curl the Google Latitude Badge API into a variable. Then parse the variable through json_decode into an array, then parse that through json_encode so its back into a single variable and has been cleaned. I then did a check to see if the data is encapsulated in brackets ( ), if not (which it isnt at them moment) i add them. Then output the application/x-javascript content-type header and echo the cleaned json variable. I can now call my script via window.location.href+"?user=1234" which will output cleaned json encapsulated in brackets. PHP CODE: <code> <?php if(!empty($_GET['user'])){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://www.google.com/latitude/apps/ badge/api?user=".$_GET['user']."&type=json"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 120); $response = curl_exec($ch); if(curl_errno($ch)){ echo curl_error($ch); }else{ $json = json_encode(json_decode($response)); if(substr($json,0,1) != "(") $json = "(".$json; if(substr($json,-1) != ")") $json = $json.")"; header('Content-Type: application/x-javascript; charset=utf-8'); echo $json; } curl_close($ch); }else{ ?> --- your html --- <?php } ?> </code> So you think this would work in $.getJSON now, it doesnt, i dont know why. So instead i load it via $.get and eval() the data which works. JAVASCRIPT: <code> $.get(window.location.href+"?user=1234", function(data){ $.each(eval(data), function(i,item){ alert(i+"=>"+item); }); }); </code> Hope this helps people! On Jul 29, 12:29 am, yaphi <jconto...@gmail.com> wrote: > Hello, > > I am trying to request the json feed from Google Latitude. This script > is working perfectly in Safari 4, but I get a 400 Bad Request error in > FF 3.5. If I add the &callback=? to the end of the URL, then FF 3.5 > hits me with an Invalid Label error which I can't work around (tried > eval). Also, adding &callback=? to the end of the URL results in a > syntax error in result in Safari 4. > > Can anyone point me in the right direction here? > > <code> > <script src="http://www.google.com/jsapi"></script> > <script type="text/javascript" charset="utf-8"> > > // Just using the google ajax library service for simplicity sake. > Replace this with the regular jQuery installation > > google.load("jquery", "1"); > google.setOnLoadCallback(function() { > loadLatitudeLocationData(); > }); > > function loadLatitudeLocationData() > { > var url = "http://www.google.com/latitude/apps/badge/api? > user=1798529584061495106&type=json"; > $.getJSON(url, > function(data) { > var features = data.features; > console.log(features[0].properties.reverseGeocode); > }); > } > </script> > </code>