PHP code example of lucky-loek / really-simple-http-requests
1. Go to this page and download the library: Download lucky-loek/really-simple-http-requests 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/ */
lucky-loek / really-simple-http-requests example snippets
$request = new Request(
'www.httpbin.org/post',
'post',
'This is a nice body!',
[
'X-Csrf-Token' => 'notSoSafeToken'
]
);
$response = $request->send();
echo $response->getBody();
echo $response->getStatusCode();
// You can secretly take a look at the headers too!
echo $response->getHeader('Content-Length');
// Get them all!
foreach $response->getAllHeaders() as $header {
echo $header;
}