コード例 #1
0
ファイル: api.php プロジェクト: Dirichi/Ushahidi_Web
 /**
  * Starting point
  */
 public function index()
 {
     // Disables CSRF validation for API requests
     Validation::$is_api_request = TRUE;
     // Reset session for API requests - since they don't get CSRF checked
     // AJAX requests are ok - they skip CSRF anyway.
     if (!request::is_ajax()) {
         // Reset the session - API should be stateless
         $_SESSION = array();
         // Especially reset auth
         Session::instance()->set(Kohana::config('auth.session_key'), null);
         // Re-authenticate
         $this->auth->http_auth_login();
     }
     // Instantiate the API service
     $api_service = new Api_Service();
     // Run the service
     $api_service->run_service();
     // Avoid caching
     header("Cache-Control: no-cache, must-revalidate");
     // HTTP/1.1
     header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
     // Date in the past
     $resp = '';
     if ($api_service->get_response_type() == 'jsonp') {
         header("Content-type: application/json; charset=utf-8");
         $resp = $_GET['callback'] . '(' . $api_service->get_response() . ')';
     } elseif ($api_service->get_response_type() == 'xml') {
         header("Content-type: text/xml");
         $resp = $api_service->get_response();
     } else {
         header("Content-type: application/json; charset=utf-8");
         $resp = $api_service->get_response();
     }
     print $resp;
 }
コード例 #2
0
ファイル: api.php プロジェクト: kh411d/Ushahidi_Web
 /**
  * Starting point
  */
 public function index()
 {
     // Instantiate the API service
     $api_service = new Api_Service();
     // Run the service
     $api_service->run_service();
     // Avoid caching
     header("Cache-Control: no-cache, must-revalidate");
     // HTTP/1.1
     header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
     // Date in the pas
     if ($api_service->get_response_type() == 'xml') {
         header("Content-type: text/xml");
     }
     print $api_service->get_response();
 }
コード例 #3
0
ファイル: api.php プロジェクト: nanangsyaifudin/HAC-2012
 /**
  * Starting point
  */
 public function index()
 {
     // Disables CSRF validation for API requests
     Validation::$is_api_request = TRUE;
     // Instantiate the API service
     $api_service = new Api_Service();
     // Run the service
     $api_service->run_service();
     // Avoid caching
     header("Cache-Control: no-cache, must-revalidate");
     // HTTP/1.1
     header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
     // Date in the pas
     if ($api_service->get_response_type() == 'xml') {
         header("Content-type: text/xml");
     } else {
         header("Content-type: application/json; charset=utf-8");
     }
     print $api_service->get_response();
 }