![]() |
How To Use Curl In Php For Json Results From Google Places Api
I used my API key for querying google places API for obtaining museums around a particular place and obtained the following results in JSON form:
{ "html_attributions" : [], "results" : [ { "geometry" : { "location" : { "lat" : 15.4954990, "lng" : 73.82120 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/museum-71.png", "id" : "1f1425a4048b951552591838918fddcfa92ce0a9", "name" : "Museum", "reference" : "CpQBgQAAABj0cBhH-lN_qR75O8cH-CaRqZxZyY98edwHytsuW3hEgA9YX0L9Q5lNSxxJkWKc4hQWZaBie4rAxF6toH1gfcF-EH-8aidpfccqXH7Y6UyN06gNRtaMZtX4KdoQfoDrMvcLPxlpC519Aa6ZFBWII7agaGJ8x3-4Bi7PDIH3nqe6h7ywvQFI12sXh80VE7DhuhIQ-vAeCJylozUNoeZdYEIvLRoUYjxWFbm08-HG-7RIt1JBNcCOsyI", "types" : [ "museum", "establishment" ], "vicinity" : "Althino, Panaji (Panjim)" } ], "status" : "OK" } Then I wrote the following code to obtain only certain data from the JSON result i.e name,type,vicinity Code:
null null null what do i do next? don't know what the error in the code is. i need to insert the specific data from JSON result that i have got into a database. |
You are using var_dump all wrong...Just use plain assignment(or Output buffering which is unnecessary in this case).
PHP Code:
First, make sure that the cURL function is returning data. Place this code below $geoloc = json_decode(curl_exec($ch), true); Then post the results here. PHP Code:
|
case solved.
|
| All times are GMT +1. The time now is 12:19 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.