PHP code example of adeelnawaz / polr-api-bundle
1. Go to this page and download the library: Download adeelnawaz/polr-api-bundle 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-bundle example snippets
// config/bundles.php
return [
...,
Adeelnawaz\PolrApiBundle\PolrApiBundle::class => ['all' => true],
];
namespace App\Controller;
use Adeelnawaz\PolrApiBundle\Service\PolrApiService;
use Adeelnawaz\PolrApiClient\DTO\Link;
use Adeelnawaz\PolrApiClient\Exception\ApiResponseException;
class DefaultController extends AbstractController
{
public function indexAction(PolrApiService $api)
{
// Prepare DTO for API method input
$link = new 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 {
$responseLink = $api->shortenLink($link);
print_r($responseLink);
} catch (ApiResponseException $e) {
echo "Error: ({$e->getCode()} - {$e->getErrorCode()}) \"{$e->getMessage()}\"\n";
}
}
}