PHP code example of headzoo / web-tools
1. Go to this page and download the library: Download headzoo/web-tools 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/ */
headzoo / web-tools example snippets
use Headzoo\Web\Tools\WebClient;
use Headzoo\Web\Tools\HttpMethods;
// Make a simple GET request.
$web = new WebClient();
$response = $web->get("http://headzoo.io");
// Make a simple POST request.
$web = new WebClient();
$response = $web->post("http://headzoo.io", ["arg1" => "value1"]);
// The response is an instance of WebResponse, which provides the response information.
echo $response->getCode();
echo $response->getBody();
print_r($response->getHeaders());
// Making a requests with more configuration.
$web = new WebClient(HttpMethods::GET);
$web
->addHeader("Content-Type", "application/json")
->setUserAgent("My-Web-Client")
->setBasicAuth("headzoo", "password");
$response = $web->request("http://headzoo.io");