Mit der folgende Routine können URL´s mit Googles Kurz-URL Dienst goo.gl gekürzt werden. Das Script erfordert einen kostenlosen Google API Key.
<?php function getgoogl($glurl, $apikey) { $userurl = rawurlencode($glurl); $ch = curl_init('https://www.googleapis.com/urlshortener/v1/url?key='.$apikey); curl_setopt_array($ch, array( CURLOPT_POST => TRUE, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_HTTPHEADER => array('Content-type: application/json'), CURLOPT_POSTFIELDS => json_encode(array('longUrl' => $userurl)) )); $chresults = json_decode(curl_exec($ch)); curl_close($ch); return $chresults->id; } ?>