1. Go to this page and download the library: Download stk2k/net-driver 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/ */
stk2k / net-driver example snippets
use Stk2k\NetDriver\Drivers\Curl\CurlNetDriver;
$driver = new CurlNetDriver();
$request = new HttpGetRequest($driver, 'http://sazysoft.com/test/');
$handle = $driver->newHandle();
try{
$response = $driver->sendRequest($handle, $request);
echo $response->getBody();
}
catch(NetDriverException $e)
{
// error handling here
}
use Stk2k\NetDriver\Drivers\Php\PhpNetDriver;
$driver = new PhpNetDriver();
$request = new HttpGetRequest($driver, 'http://sazysoft.com/test/');
$handle = $driver->newHandle();
try{
$response = $driver->sendRequest($handle, $request);
echo $response->getBody();
}
catch(NetDriverExceptionInterface $e)
{
// error handling here
}
$driver = new CurlNetDriver();
$request = new HttpGetRequest($driver, 'http://sazysoft.com/test/');
$handle = $driver->newHandle();
try{
$driver->listen('request', function(HttpRequest $request){
$request->addHttpHeader('Content-Type', 'text/json'); // set content type to text/json
return $request; // replace old request to new one
});
$response = $driver->sendRequest($handle, $request);
echo $response->getBody();
}
catch(NetDriverExceptionInterface $e)
{
// error handling here
}