PHP code example of wernerdweight / curler
1. Go to this page and download the library: Download wernerdweight/curler 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/ */
wernerdweight / curler example snippets
use WernerDweight\Curler\Curler;
use WernerDweight\Curler\Request;
$curler = new Curler();
$request = (new Request())
->setEndpoint('https://some-website.tld')
->setMethod('POST')
->setPayload(['key' => 'value'])
->setHeaders(['Accept: text/html', 'Accept-Encoding: gzip'])
->setAuthentication('user', 'password')
;
$response = $curler->request($request);
echo $response->text(); // '<html>...</html>'
var_dump($response->getMetaData()); // array of response metadata (content-type, status...)