PHP code example of adeelnawaz / polr-api-client

1. Go to this page and download the library: Download adeelnawaz/polr-api-client 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/ */

    

adeelnawaz / polr-api-client example snippets


// Register composer spl autoload
$autoloader = lnawaz\PolrApiClient\PolrApi(
    "POLR_API_URL",
    "POLR_API_KEY",
    "POLR_API_QUOTA"
);

// Prepare DTO for API method input
$link = new \Adeelnawaz\PolrApiClient\DTO\Link();
$link->setUrl('https://www.google.com/search?tbm=isch&source=hp&biw=1863&bih=916&ei=IksNW5eLHqzisAfvgKKQBg&q=samurai+jack&oq=samurai+jack&gs_l=img.3..0l10.799.2671.0.2891.13.10.0.3.3.0.54.372.9.9.0....0...1ac.1.64.img..1.12.380.0...0.NlHgI6Y6mmY')
    ->setIsSecret(true);

try {
    /**
     * @var \Adeelnawaz\PolrApiClient\DTO\Response\Link $responseLink
     */
    $responseLink = $api->shortenLink($link);

    print_r($responseLink);
} catch (\Adeelnawaz\PolrApiClient\Exception\ApiResponseException $e) {
    echo "Error: ({$e->getCode()} - {$e->getErrorCode()}) \"{$e->getMessage()}\"\n";
}