This is a library module. It provides no out of the box functionality other then providing an API that other modules can use.
The Webclient API is seperated into three major components:
- Webclient
- Webclient Formatters
- Webclient Proxy
All of the above components were translated to seperate modules so that developers can create a dependency with the functionality they need.
Webclient
Creates an API wrapper around cURL using an OO-based approach thus providing a more intuitive way of managing and retrieving request and response data.
As of WebClient 7.x-1.2 integration with the Drupal HTTP API is available without the need of additional extensions or modules. See #1930196: Override drupal_http_request() using Drupal variable for more info.
Webclient Formatters
A formatter is way of transforming raw response data into usable data, e.g. converting a JSON string into an object or array.
The Webclient Formatters module provides the following MIME type support out of the box:
- application/json
- text/xml
- text/html
However new formatters can be added using the hook_webclient_response_formatter_info().
Webclient Proxy
The Webclient Proxy module provides proxy support for all Webclient requests. A user can use the administration page to add proxy servers and configure which modules should use a proxy.
An implementing module should use the hook_webclient_proxy_supported_request() to inform the Webclient Proxy module about its usage thus allowing a different proxy or none to be used when creating requests.
As of WebClient 7.x-1.2 the Drupal proxy settings can be used in the WebClient proxy configuration. See #1930192: Support proxy settings provided by Drupal for more info.
Webclient Extension
This submodule is deprecated as of 7.x-1.2 and can only be used in Drupal 7.21 or lower installations. See #1930196: Override drupal_http_request() using Drupal variable for more info.
The Webclient Extension module changes the drupal_http_request() implementation so that the Drupal core and contrib modules using the drupal_http_request() function can take advantage of the features provided by Webclient.
Warning: requires the PHP runkit or APD extension!
Example usage
Create a request using webclient_request() and retrieve the request object without actually performing the request:
// Configure the webclient_request().
$options = array(
// Allow other modules to identify the Webclient request:
'tags' => array('mymodule_some_request'),
);
// Construct the request and retrieve the request object.
$request = webclient_request('http://www.somepage.com', $options);
Create a request using webclient_request() and retrieve the response object:
// Configure the webclient_request().
$options = array(
// Allow other modules to identify the Webclient request:
'tags' => array('mymodule_some_request'),
// Inform the webclient_request that we want the response object.
'return' => WEBCLIENT_RESPONSE,
);
// Perform request and retrieve the response object.
$response = webclient_request('http://www.somepage.com', $options);
Create a request using webclient_request() and retrieve the raw response data:
// Configure the webclient_request().
$options = array(
// Allow other modules to identify the Webclient request:
'tags' => array('mymodule_some_request'),
// Inform the webclient_request that we want raw response data.
'return' => WEBCLIENT_RESPONSE_RAW,
);
// Perform request and retrieve the raw response data.
$raw_response = webclient_request('http://www.somepage.com', $options);
Create a request using webclient_request() and retrieve the formatted response:
// Configure the webclient_request().
$options = array(
// Allow other modules to identify the Webclient request:
'tags' => array('mymodule_some_request'),
// Inform the webclient_request that we want formatted response data.
'return' => WEBCLIENT_RESPONSE_FORMATTED,
);
// Perform request and retrieve the formatted response data.
$formatted_response = webclient_request('http://www.somepage.com', $options);
Project information
12 sites report using this module
- Created by vacilando on , updated
Stable releases for this project are covered by the security advisory policy.
There are currently no supported stable releases.
