DokuWiki

It's better when it's simple

User Tools

Site Tools


devel:httpclient

HTTPClient Library

DokuWiki provides a library to access remote web servers without the need for any special PHP library (like CURL) or unsafe PHP settings (like allow_url_fopen).

The following features are supported:

  • Communication directly via network sockets
  • SSL support (if enabled in PHP)
  • Configurable timeouts
  • Proxy support
  • Redirect following
  • HTTP header parser
  • Basic authentication
  • Chunked encoding

The client is implemented in the class dokuwiki\HTTP\HTTPClient, but it is recommended to access the library through the dokuwiki\HTTP\DokuHTTPClient subclass instead. This automatically configures the client correctly for using the proxy settings.

Examples

Simple GET

$http = new dokuwiki\HTTP\DokuHTTPClient();
$data = $http->get('http://www.google.com/');
echo $data;

Simple POST

use dokuwiki\HTTP\DokuHTTPClient;
 
// post data can be passed as associative array
$send = [
    'p' => 'dokuwiki'
];
$http = new DokuHTTPClient();
$data = $http->post('http://search.yahoo.com/search', $send);
echo $data;
devel/httpclient.txt · Last modified: 2023-09-16 00:53 by Klap-in

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki