PHP code example of thomxc / guzzleplug

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

    

thomxc / guzzleplug example snippets




class Service extends GuzzlePlug\GuzzlePlug
{
    public function __construct($url = 'https://api.myservice.com')
    {
        $this->url = $url;
    }
    
    public function getRequest()
    {
        $response = $this->request('GET', $this->url);
        if ($this->actualResponse->getStatusCode() == 200) {
            return $response;
        } else {
            throw new Exception('Response status code != 200');
        }
    }
}