Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Api_Controller extends Controller {
- /**
- * 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 past
- $callback = '';
- $resp = "";
- if ($api_service->get_response_type() == 'jsonp')
- {
- header("Content-type: application/json; charset=utf-8");
- $resp = $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;
- }
- }
Add Comment
Please, Sign In to add comment