Class WebRequest
Documentation of includes/core/webrequest.class.php
Provides asynchronous and synchronous communication for HTTP GET-, POST- and HEAD-Requests.
Methods
GET
Handles HTTP-GET requests.
Description
string = GET ( array $params )Parameters
- 
urlRequired: String with an HTTP-URL which should be requested. 
- 
callbackOptional/Required: The callback which should be called when the request is finished (only required for asynchronous requests). 
- 
syncOptional: Switch for asynchronous and synchronous requests, default value is false.
- 
timeoutOptional: Over all timeout in seconds after the request should give up, default value is 20.
- 
timeout_dnsOptional: DNS request timeout in seconds after that the request should give up, default value is 5.
- 
timeout_connectOptional: Connection timeout in seconds after that the request should give up, default value is 5.
- 
triesOptional: Amount of tries until the request should give up, default value is 10.
- 
max_redirectOptional: Follow max. this amount of redirects, default value is 50.
- 
user_agentOptional: String which will be used as USER-AGENT within the request. 
- 
extra_headersOptional: Array which holds extra headers to add to the request, e.g. array('X-ServerLogin: labs01','X-ServerNation: DEU').
Example
public function example () {
    try {
        // Grab a text file
        $params = array(
            'url'       => 'http://www.uaseco.org/uptodate/current_release.txt',
            'callback'  => array(array($this, 'handleWebrequest'), $login),
        );
        $result = $aseco->webrequest->GET($params);
    }
    catch (Exception $exception) {
        $aseco->console('[UpToDate] webrequest->get(): '. $exception->getCode() .' - '. $exception->getMessage() ."\n". $exception->getTraceAsString(), E_USER_WARNING);
        return false;
    }
}
public function handleWebrequest ($request, $login = false) {
    // Handle the request answer here...
}POST
Handles HTTP-POST requests.
Description
string = POST ( array $params )Parameters
- 
urlRequired: String with an HTTP-URL which should be requested. 
- 
dataRequired: Data for the request body of a POST-Request, only required at POST-Request). 
- 
callbackOptional/Required: The callback which should be called when the request is finished (only required for asynchronous requests). 
- 
syncOptional: Switch for asynchronous and synchronous requests, default value is false.
- 
timeoutOptional: Over all timeout in seconds after the request should give up, default value is 20.
- 
timeout_dnsOptional: DNS request timeout in seconds after that the request should give up, default value is 5.
- 
timeout_connectOptional: Connection timeout in seconds after that the request should give up, default value is 5.
- 
triesOptional: Amount of tries until the request should give up, default value is 10.
- 
max_redirectOptional: Follow max. this amount of redirects, default value is 50.
- 
user_agentOptional: String which will be used as USER-AGENT within the request. 
- 
extra_headersOptional: Array which holds extra headers to add to the request, e.g. array('X-ServerLogin: labs01','X-ServerNation: DEU').
Example
public function example () {
    try {
        // Grab a text file
        $params = array(
            'url'       => 'http://www.uaseco.org/example.php',
            'data'      => $data,                       // e.g. CSV-, XML-Data or an Image
            'callback'  => array(array($this, 'handleWebrequest'), $login),
        );
        $result = $aseco->webrequest->POST($params);
    }
    catch (Exception $exception) {
        $aseco->console('[UpToDate] webrequest->get(): '. $exception->getCode() .' - '. $exception->getMessage() ."\n". $exception->getTraceAsString(), E_USER_WARNING);
        return false;
    }
}
public function handleWebrequest ($request, $login = false) {
    // Handle the request answer here...
}HEAD
Handles HTTP-HEAD requests.
Description
string = HEAD ( array $params )Parameters
- 
urlRequired: String with an HTTP-URL which should be requested. 
- 
timeoutOptional: Over all timeout in seconds after the request should give up, default value is 20.
- 
timeout_dnsOptional: DNS request timeout in seconds after that the request should give up, default value is 5.
- 
timeout_connectOptional: Connection timeout in seconds after that the request should give up, default value is 5.
- 
triesOptional: Amount of tries until the request should give up, default value is 10.
- 
max_redirectOptional: Follow max. this amount of redirects, default value is 50.
- 
user_agentOptional: String which will be used as USER-AGENT within the request. 
- 
extra_headersOptional: Array which holds extra headers to add to the request, e.g. array('X-ServerLogin: labs01','X-ServerNation: DEU').
Example
public function example () {
    try {
        // Does the file exists?
        $params = array(
            'url'       => 'http://www.uaseco.org/uptodate/current_release.txt',
        );
        $result = $aseco->webrequest->HEAD($params);
    }
    catch (Exception $exception) {
        $aseco->console('[UpToDate] webrequest->get(): '. $exception->getCode() .' - '. $exception->getMessage() ."\n". $exception->getTraceAsString(), E_USER_WARNING);
        return false;
    }
}This is a private enthusiast Website. Maniaplanet, Trackmania, Shootmania, Nadeo are trademarks of Ubisoft Entertainment.
				Windows is a registered trademark of Microsoft Corporation.

