/** * locationGenerator with the coordinates data, it connects to * Google Place API for get more information about location. * This function builds a location array ready to be listed. * * @param int $media_id * @param array $location * @return array response * int response[id] instagram media id * array response[location][geopoint] coordinates * string response[location][reference] coordinate reference * provides by google * string response[location][address] coordinate address * provides by google * int response[location][id] instragram location id * string response[location][name] instragram location name */ private function locationGenerator($media_id, $location) { $response = array('id' => $media_id, 'location' => null); if (!empty($location->latitude) && !empty($location->longitude)) { $google_data = $this->place->get($location->latitude, $location->longitude); $response['location'] = array('geopoint' => array('latitude' => $location->latitude, 'longitude' => $location->longitude), 'reference' => $google_data['reference'], 'address' => $google_data['address']); } if (!empty($location->id)) { $response['location']['id'] = $location->id; } if (!empty($location->name)) { $response['location']['name'] = $location->name; } return $response; }