PHP code example of raph6 / httprequest
1. Go to this page and download the library: Download raph6/httprequest library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
raph6 / httprequest example snippets
use raph6\HttpRequest\HttpRequest;
# url
$http = new HttpRequest('https://httpbin.org/anything');
# or
$http = new HttpRequest;
$http->setUrl('https://httpbin.org/anything')
# cookies
->setCookies(['bar' => 'foo'])
# data (get or post)
->setData(['foo' => 'bar'])
# headers
->setHeaders(['token' => '123456'])
# user agent
->setUserAgent('PHP/Curl (https://github.com/raph6/httprequest)')
# basic auth
->setBasicAuth('username', 'password')
# timeout (default 10)
->setTimeout(5);
var_dump($http->post());
// var_dump($http->get());