コード例 #1
0
 /**
  * We run the api we setup in setup_supported_apis()
  *
  * Note that we ask for the content type and set the content differently for the json and html content types.
  *
  * If the content type is not 'json' or 'html', note that we run the api anyway, as it supports standard error cases.
  */
 function run_api()
 {
     $api = $this->get_api();
     if ($api->get_name() == 'random_number') {
         if ($api->get_content_type() == 'json') {
             $api->set_content(json_encode(array('random_number' => $this->get_random_number())));
         }
         if ($api->get_content_type() == 'html') {
             $api->set_content('<p>' . $this->get_random_number() . '</p>');
         }
         $api->run();
     } else {
         parent::run_api();
     }
     // support other apis defined by parents
 }
コード例 #2
0
 function run_api()
 {
     $api = $this->get_api();
     if ($api->get_name() == 'image_detail') {
         if ($api->get_content_type() == 'html') {
             $api->set_content($this->get_image_detail_content());
         }
         $api->run();
     } else {
         parent::run_api();
     }
     // support other apis defined by parents
 }