1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <?php
- if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
- }
- class GeocodeAction extends Action
- {
- var $lat = null;
- var $lon = null;
- var $location = null;
- function prepare(array $args = array())
- {
- parent::prepare($args);
- $token = $this->trimmed('token');
- if (!$token || $token != common_session_token()) {
-
- $this->clientError(_('There was a problem with your session token. '.
- 'Try again, please.'));
- }
- $this->lat = $this->trimmed('lat');
- $this->lon = $this->trimmed('lon');
- $this->location = Location::fromLatLon($this->lat, $this->lon);
- return true;
- }
-
- function handle()
- {
- header('Content-Type: application/json; charset=utf-8');
- $location_object = array();
- $location_object['lat']=$this->lat;
- $location_object['lon']=$this->lon;
- if($this->location) {
- $location_object['location_id']=$this->location->location_id;
- $location_object['location_ns']=$this->location->location_ns;
- $location_object['name']=$this->location->getName();
- $location_object['url']=$this->location->getUrl();
- }
- print(json_encode($location_object));
- }
-
- function isReadOnly($args)
- {
- return true;
- }
- }
|