本文整理汇总了PHP中external_api::set_timeout方法的典型用法代码示例。如果您正苦于以下问题:PHP external_api::set_timeout方法的具体用法?PHP external_api::set_timeout怎么用?PHP external_api::set_timeout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类external_api
的用法示例。
在下文中一共展示了external_api::set_timeout方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Process request from client.
* @return void
*/
public function run()
{
global $WEBSERVICE_FUNCTION_RUN, $USER, $WEBSERVICE_INSTITUTION, $WEBSERVICE_START;
$WEBSERVICE_START = microtime(true);
// we will probably need a lot of memory in some functions
raise_memory_limit('128M');
// set some longer timeout, this script is not sending any output,
// this means we need to manually extend the timeout operations
// that need longer time to finish
external_api::set_timeout();
// set up exception handler first, we want to sent them back in correct format that
// the other system understands
// we do not need to call the original default handler because this ws handler does everything
set_exception_handler(array($this, 'exception_handler'));
// init all properties from the request data
$this->parse_request();
// authenticate user, this has to be done after the request parsing
// this also sets up $USER and $SESSION
$this->authenticate_user();
// find all needed function info and make sure user may actually execute the function
$this->load_function_info();
// finally, execute the function - any errors are catched by the default exception handler
$this->execute();
$time_end = microtime(true);
$time_taken = $time_end - $WEBSERVICE_START;
//log the web service request
$log = (object) array('timelogged' => time(), 'userid' => $USER->get('id'), 'externalserviceid' => $this->restricted_serviceid, 'institution' => $WEBSERVICE_INSTITUTION, 'protocol' => 'REST', 'auth' => $this->auth, 'functionname' => $this->functionname, 'timetaken' => "" . $time_taken, 'uri' => $_SERVER['REQUEST_URI'], 'info' => '', 'ip' => getremoteaddr());
insert_record('external_services_logs', $log, 'id', true);
// send the results back in correct format
$this->send_response();
// session cleanup
$this->session_cleanup();
die;
}
示例2: run
/**
* Process request from client.
*
* @uses die
*/
public function run()
{
// we will probably need a lot of memory in some functions
raise_memory_limit(MEMORY_EXTRA);
// set some longer timeout, this script is not sending any output,
// this means we need to manually extend the timeout operations
// that need longer time to finish
external_api::set_timeout();
// set up exception handler first, we want to sent them back in correct format that
// the other system understands
// we do not need to call the original default handler because this ws handler does everything
set_exception_handler(array($this, 'exception_handler'));
// init all properties from the request data
$this->parse_request();
// authenticate user, this has to be done after the request parsing
// this also sets up $USER and $SESSION
$this->authenticate_user();
// find all needed function info and make sure user may actually execute the function
$this->load_function_info();
// Log the web service request.
$params = array('other' => array('function' => $this->functionname));
$event = \core\event\webservice_function_called::create($params);
$event->set_legacy_logdata(array(SITEID, 'webservice', $this->functionname, '', getremoteaddr(), 0, $this->userid));
$event->trigger();
// finally, execute the function - any errors are catched by the default exception handler
$this->execute();
// send the results back in correct format
$this->send_response();
// session cleanup
$this->session_cleanup();
die;
}
示例3: run
/**
* Runs the SOAP web service.
*
* @throws coding_exception
* @throws moodle_exception
* @throws webservice_access_exception
*/
public function run()
{
// We will probably need a lot of memory in some functions.
raise_memory_limit(MEMORY_EXTRA);
// Set some longer timeout since operations may need longer time to finish.
external_api::set_timeout();
// Set up exception handler.
set_exception_handler(array($this, 'exception_handler'));
// Init all properties from the request data.
$this->parse_request();
// Authenticate user, this has to be done after the request parsing. This also sets up $USER and $SESSION.
$this->authenticate_user();
// Make a list of all functions user is allowed to execute.
$this->init_service_class();
if ($this->wsdlmode) {
// Generate the WSDL.
$this->generate_wsdl();
}
// Log the web service request.
$params = array('other' => array('function' => 'unknown'));
$event = \core\event\webservice_function_called::create($params);
$logdataparams = array(SITEID, 'webservice_soap', '', '', $this->serviceclass . ' ' . getremoteaddr(), 0, $this->userid);
$event->set_legacy_logdata($logdataparams);
$event->trigger();
// Handle the SOAP request.
$this->handle();
// Session cleanup.
$this->session_cleanup();
die;
}