How can I extract value from json?


#1

Hi everyone

I’m having some trouble extracting from the JSON returned by the reverse geo api call.
I am able to echo out values in the query section but not the results section. Any help would be greatly appreciated because I really can’t get my head around what the issue would be and i have a suspicion its something glaringly obvious.

This is my code:
$data = $twitter->get(‘https://api.twitter.com/1.1/geo/reverse_geocode.json?lat=37.76893497&long=-122.42284884’);

echo $data->query->params->granularity;
//this prints out “neighbourhood” fine

foreach ($data as $item) { //cant get any of the below to print out though!
echo $item->result->places->contained_within->attributes->full_name;
echo $item->result->places->full_name;
echo $item->places->full_name;
echo $item->result->full_name;
echo $item->full_name;
}