PHP code example of nattaponra / google-short-url-php
1. Go to this page and download the library: Download nattaponra/google-short-url-php 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/ */
nattaponra / google-short-url-php example snippets
// If your don't has api key please read this document > https://developers.google.com/identity/protocols/OAuth2
$apiKey = "XxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxX";
$goo = new Googl($apiKey);
$shortUrl = "https://github.com";
$resultOfShortening = $goo->shorten($shortUrl);
print_r($resultOfShortening);
// Result utl : https://goo.gl/un5E
$longUrl = "https://goo.gl/un5E";
$resultOfExpansion = $goo->expand($longUrl);
print_r($resultOfExpansion);
// Result utl : https://github.com
$result = $goo->lookUpAnalytics("https://goo.gl/un5E");
print_r($result);