PHP code example of openprovider / http

1. Go to this page and download the library: Download openprovider/http 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/ */

    

openprovider / http example snippets


use \Openprovider\Service\Http\Request;
use \Openprovider\Service\Http\Response;

$response = Request::get('google.com')->execute();
$status = $response->getHttpStatusCode();
if ($response->isSuccess) {
    $cookie = $response->getCookie();
    $header = $response->getHeader();
    $data = $response->getData();
} else {
    print_r($response->getErrorCode() . ': ' . $response->getErrorDescription());
}

use \Openprovider\Service\Http\Request;
use \Openprovider\Service\Http\Response;

$request = new Request('website.com');
$response = $request->setFollowLocation(false)
    ->setMethod(Request::POST)
    ->setTimeout(10)
    ->setCookie('PREF=ID; Name=Noname')
    ->execute();