PHP code example of hadesker / request
1. Go to this page and download the library: Download hadesker/request 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/ */
hadesker / request example snippets
$req = new \Hadesker\Request\Request();
$req->setUrl('https://abc.com/login');
$req->setFormType(\Hadesker\Request\Request::$FORM_TYPE_ENCODED) // $FORM_TYPE_DATA or $FORM_TYPE_JSON or $FORM_TYPE_ENCODED (default)
$req->setHeaders([
'Auth'=> 'Bearer sgafaksdfasd',
'User-Agent'=> 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.35 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.35',
]);
$req->setCookie('name', 'value');
$req->setBodies([
'username' => 'something',
'password' => '123456',
]);
$req->post();
var_dump($req->getCookies());
var_dump($req->getHeaders());
var_dump($req->getResponse());
die();