User Tools

Site Tools


HTTP Client

litecarts HTTP Client uses the Unix domain socket for HTTP Client connections.

To initiate an http client call you have to implement the http_client class:

$client = new http_client();

Now you are allowed to use the call() function. To see how to setup the call look at the following code snippet:

call($method, $url='', $data=null, $headers=array(), $asynchronous=false)
  • $method: choose the type of request ⇒ POST || GET
  • $url: Set the target URL
  • $data: Set the Request-Data
  • $headers: An Array for the HTTP Header ⇒ The Key of the Array describes the parameter and the Value the argument ('Content-Type' ⇒ 'application/json')
  • $asynchronous: Set true for an asynchronous Request and false (default) for an synchronous HTTP Request

Code Example

$client = new http_client();
$response = $client→call('POST', 'http://...', $data, $extra_headers);

The $response Variable holds the return Value of the client call. Read it with var_dump() to process the data.

classes/http_client.txt · Last modified: 2018/08/12 10:08 by freshlix