cachetime = 86400; $this->service = strtolower( get_class( $this ) ); $this->data = null; $this->LoadData( ); } protected function LoadData( ) { $this->LoadRemote( ); } public function GetData( $callback = null ) { $data = json_encode( $this->data ); if( is_null( $callback ) ) { return $data; } else { return "{$callback}({$data})"; } } protected abstract function LoadRemote( ); } if( TryGetParam( 'service', $service ) ) { $service = strtolower( $service ); $apifile = "api/{$service}.php"; if( file_exists( $apifile ) ){ include( $apifile ); $api = new $service( ); if( TryGetParam( 'callback', $callback ) ) { header( 'Content-type:text/javascript' ); echo $api->GetData( $callback ); } else { header( 'Content-type:application/json' ); echo $api->GetData( ); } } }