private function getExperiments() { $weblab_data = $this->getWeblabData(); $weblab = new WebLabDeusto($weblab_data[0]); $sess_id = $weblab->login($weblab_data[1], $weblab_data[2]); $experiments = $weblab->list_experiments($sess_id); return $experiments; }
private function getExperiment($username, $exp_name, $cat_name) { $weblab_data = $this->getWeblabData(); $weblab = new WebLabDeusto($weblab_data[0]); $sess_id = $weblab->login($weblab_data[1], $weblab_data[2]); $consumer_data = array("user_agent" => $_SERVER['HTTP_USER_AGENT'], "from_ip" => $_SERVER['REMOTE_ADDR'], "external_user" => $username); $reservation_status = $weblab->reserve($sess_id, $exp_name, $cat_name, "{}", $consumer_data); $reservation_status = $weblab->get_reservation_status($reservation_status->reservation_id); $client_url = $weblab->create_client($reservation_status); return $client_url; }
<?php require "weblabdeusto.class.php"; //////////////////// // // Usage sample // We log in: // // Default (HTTPCLIENT) $weblab = new WebLabDeusto("http://localhost/weblab/"); // Using HttpClient: instance-level cookies; no support for HTTPS // $weblab = new WebLabDeusto("http://localhost/weblab/", WebLabHttpRequestGateway::$HTTPCLIENT); // // Using CURL: support for HTTPS; cookies stored in file: common to // all requests. If the login cookie expires while another request // is in process, this request fails // $weblab = new WebLabDeusto("http://localhost/weblab/", WebLabHttpRequestGateway::$CURL); // additional optional argument: cookiefile // Using CURL with different cookie file // $weblab = new WebLabDeusto("http://localhost/weblab/", WebLabHttpRequestGateway::$CURL, "cookiefile"); echo "Using http gateway: " . $weblab->getGatewayName() . "<br/>\n"; $sess_id = $weblab->login("any", "password"); ////////////////////////////////////////////// // // Ask for the available experiments (with session_id) // (see "ExperimentPermission") // $experiments = $weblab->list_experiments($sess_id); foreach ($experiments as $experiment) { echo "I have permission " . $experiment->name . " of category " . $experiment->category . " during " . $experiment->assigned_time . " seconds <br/>\n"; } ////////////////////////////////////////