here is my PHP script.
do2:locu alexus$ cat venuesearch.php
<?php
$KEY='XXXXXXXXXXXXXXX';
$URL='http://api.locu.com/v1_0/venue/search/?api_key=';
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $URL.$KEY);
curl_setopt($ch, CURLOPT_HEADER,0);
print_r(json_decode(curl_exec($ch),TRUE));
?>
do2:locu alexus$
locu service provides output in JSON format. When I run script I'm getting output all in long single line.
sample of output:
do2:locu alexus$ php venuesearch.php
{"meta": {"cache-expiry": 3600, "limit": 25}, "objects": [{"categories": ["restaurant"], "country": "United States",..........
What am I missing? How can I access each of those variables? maybe it makes sense to convert it into XML?
* UPDATE * : .. in example #1 of PHP: json_decode - Manual shows formated output, if I use true then I get array, I'm not getting neither formatet output nor array.
json_decode. Are you sure you are not printing the response directly? And no, it does not make sense to convert a data format into another one in this case, you just have to parse the data properly.