Where it says "// now have some fun with the results," add something like this:
echo "lat: ".$json['responseData']['results'][0]['lat']; echo "lng: ".$json['responseData']['results'][0]['lng']; That won't get the data in your database, but it should get you what you need. Jeremy R. Geerdes Effective website design & development Des Moines, IA For more information or a project quote: http://jgeerdes.home.mchsi.com http://jgeerdes.blogspot.com http://jgeerdes.wordpress.com [email protected] Unless otherwise noted, any price quotes contained within this communication are given in US dollars. If you're in the Des Moines, IA, area, check out Debra Heights Wesleyan Church! And check out my blog, Adventures in Web Development, at http://jgeerdes.blogspot.com ! On Mar 24, 2009, at 7:03 PM, webmaster wrote: > It is still not clear to me how I can extract the information about > coordinates. Is it the parmater $json wich I have to use in > connection with other functions? Can you show me an example where I > can check that this actually works (i.e. where latitude and > longitude can be extraxted and printed?) > > here below the script I am using > > <? > > Php Access > > The following code snippet demonstrates how to make a request to the > AJAX Search API from php > > $url = > "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=Paris%20Hilton > "; > > // sendRequest > // note how referer is set manually > $ch = curl_init(); > curl_setopt($ch, CURLOPT_URL, $url); > curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); > curl_setopt($ch, CURLOPT_REFERER, "http://www.serate-italiane.dk/index.php > "); > $body = curl_exec($ch); > curl_close($ch); > > // now, process the JSON string > $json = json_decode($body); > // now have some fun with the results... > > ?> > > > Since I am using an earlier version og php5.2, I am adviced to use > the following functions, together with the Services/JSON.php script > > > > <?php > if ( !function_exists('json_decode') ){ > function json_decode($content, $assoc=false){ > require_once 'Services/JSON.php'; > if ( $assoc ){ > $json = new > Services_JSON(SERVICES_JSON_LOOSE_TYPE); > } else { > $json = new Services_JSON; > } > return $json->decode($content); > } > } > > if ( !function_exists('json_encode') ){ > function json_encode($content){ > require_once 'Services/JSON.php'; > $json = new Services_JSON; > > return $json->encode($content); > } > } > ?> > > On 24/03/2009, at 22.07, Jeremy Geerdes wrote: > >> Well, if you're going to put the information in a database, it'll >> be far easier to use the RESTful side of the API with PHP, Perl, >> Java, or some other server-side script. Check out the >> documentation at the links below: >> >> http://code.google.com/apis/ajaxsearch/documentation/index.html#fonje >> http://code.google.com/apis/ajaxsearch/documentation/reference.html#_intro_fonje >> >> You'll even find code snippets that you can just about re-use for >> your purposes. >> >> Jeremy R. Geerdes >> Effective website design & development >> Des Moines, IA >> >> For more information or a project quote: >> http://jgeerdes.home.mchsi.com >> http://jgeerdes.blogspot.com >> http://jgeerdes.wordpress.com >> [email protected] >> >> Unless otherwise noted, any price quotes contained within this >> communication are given in US dollars. >> >> If you're in the Des Moines, IA, area, check out Debra Heights >> Wesleyan Church! >> >> And check out my blog, Adventures in Web Development, at >> http://jgeerdes.blogspot.com >> ! >> >> >> On Mar 24, 2009, at 4:02 PM, webmaster wrote: >> >>> Hej again Jeremy >>> >>> the users interact by submitting addresses through a form which is >>> processed by php >>> >>> What I am aiming at is to generate coordinates (through >>> LocalSearch?) and then saving the coordinates into the mysql >>> database >>> >>> Another script will be used to visualize the location on the >>> googlemap. >>> >>> I am studying the script to make the local API search, available >>> on the AJAX playground page >>> >>> I do not know javascript, but I expect that I need to reuse >>> following function. >>> >>> function OnLoad() { >>> >>> map.setCenter(new google.maps.LatLng(parseFloat(center.lat), >>> >>> parseFloat(center.lng)), >>> zoom); >>> .... >>> >>> } >>> >>> Am I right? >>> >>> Gino >>> >>> >>> On 24/03/2009, at 11.53, Jeremy Geerdes wrote: >>> >>>> >>>> There are a few possibilities here. First, if you're wanting the >>>> user >>>> to be able to specify the location, you can run address information >>>> through the LocalSearch API and get a lat/lng pair back. >>>> Alternatively, if you're just looking for an approximation of where >>>> the user is, you can just access the google.loader.ClientLocation >>>> property. And finally, if you want a fairly accurate geocode of >>>> the >>>> user without the interaction, you can use Google Gears. >>>> >>>> Jeremy R. Geerdes >>>> Effective website design & development >>>> Des Moines, IA >>>> >>>> For more information or a project quote: >>>> http://jgeerdes.home.mchsi.com >>>> http://jgeerdes.blogspot.com >>>> http://jgeerdes.wordpress.com >>>> [email protected] >>>> >>>> Unless otherwise noted, any price quotes contained within this >>>> communication are given in US dollars. >>>> >>>> If you're in the Des Moines, IA, area, check out Debra Heights >>>> Wesleyan Church! >>>> >>>> And check out my blog, Adventures in Web Development, at >>>> http://jgeerdes.blogspot.com >>>> ! >>>> >>>> >>>> On Mar 24, 2009, at 2:04 AM, webmaster wrote: >>>> >>>>> >>>>> Hi Jeremy, >>>>> >>>>> I managed to insert it as an 'iframe'. I think that iframe does >>>>> the >>>>> job. >>>>> >>>>> The last thing I would like to ask you is how I can generate >>>>> geocodes >>>>> based on the input from the users (typically address, city, >>>>> nation,) >>>>> on the fly (in batch mode?) >>>>> >>>>> I would like to generate the goecodes and then save them on the >>>>> mysql >>>>> database for further interaction through php. >>>>> >>>>> >>>>> On 24/03/2009, at 04.23, Jeremy Geerdes wrote: >>>>> >>>>>> >>>>>> It's tough to say without knowing exactly what you're trying to >>>>>> do. >>>>>> Could you provide a link to the page where you're trying to put >>>>>> this? >>>>>> >>>>>> Jeremy R. Geerdes >>>>>> Effective website design & development >>>>>> Des Moines, IA >>>>>> >>>>>> For more information or a project quote: >>>>>> http://jgeerdes.home.mchsi.com >>>>>> http://jgeerdes.blogspot.com >>>>>> http://jgeerdes.wordpress.com >>>>>> [email protected] >>>>>> >>>>>> Unless otherwise noted, any price quotes contained within this >>>>>> communication are given in US dollars. >>>>>> >>>>>> If you're in the Des Moines, IA, area, check out Debra Heights >>>>>> Wesleyan Church! >>>>>> >>>>>> And check out my blog, Adventures in Web Development, at >>>>>> http://jgeerdes.blogspot.com >>>>>> ! >>>>>> >>>>>> >>>>>> On Mar 23, 2009, at 10:15 PM, Phil wrote: >>>>>> >>>>>>> >>>>>>> Dear Experts, >>>>>>> I have managed to get the Google News Gadget to show up news >>>>>>> stories >>>>>>> about a very obscure topic: "Basic Income" as an anti-poverty >>>>>>> program. >>>>>>> >>>>>>> I am very happy with the selection of the news stories. I am >>>>>>> getting >>>>>>> exactly what I want to appear. However the title of the News >>>>>>> Gadget >>>>>>> is the search string itself which is an ugly piece of text: >>>>>>> "Basic >>>>>>> Income| Citizen's Income" etc. etc. >>>>>>> >>>>>>> Can I supply a string that will show up as the Title of the News >>>>>>> Gadget? >>>>>>> Sincerely, >>>>>>> Philip Truscott >>>>>>> >>>>>>>> >>>>>> >>>>>> >>>>>>> >>>>> >>>>> >>>>>> >>>> >>>> >>>> >>>> >>> >>> >>> >>> >> >> >> >> > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google AJAX APIs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-AJAX-Search-API?hl=en -~----------~----~----~----~------~----~------~--~---
