コード例 #1
0
ファイル: Api_Object.php プロジェクト: huslage/Ushahidi_Web
 /**
  * Response
  * 
  * @param int ret_value
  * @param string response_type = XML or JSON
  * @param string error_message - The error message to display
  * 
  * @return string
  */
 protected function response($ret_value, $error_messages = '')
 {
     $response = array();
     // Set the record count to zero where the value of @param ret_val <> 0
     $this->record_count = $ret_value != 0 ? 0 : 1;
     if ($ret_value == 0) {
         $response = array("payload" => array("domain" => $this->domain, "success" => "true"), "error" => $this->api_service->get_error_msg(0));
     } elseif ($ret_value == 1) {
         $response = array("payload" => array("domain" => $this->domain, "success" => "false"), "error" => $this->api_service->get_error_msg(03, '', $error_messages));
     } elseif ($ret_value == 2) {
         // Authentication Failed. Invalid User or App Key
         $response = array("payload" => array("domain" => $this->domain, "success" => "false"), "error" => $this->api_service->get_error_msg(05));
     } elseif ($ret_value == 4) {
         // No results got from the database query
         $response = array("payload" => array("domain" => $this->domain, "success" => "true"), "error" => $this->api_service->get_error_msg(07));
     } else {
         $response = array("payload" => array("domain" => $this->domain, "success" => "false"), "error" => $this->api_service->get_error_msg(04));
     }
     return $this->response_type == 'json' ? $this->array_as_json($response) : $this->array_as_xml($response, array());
 }