Merhaba,
Google’un URL kısaltma servisini kullanmak istiyorsanız aşağıdaki şekilde gerçekleştirebilirsiniz.
<?php
namespace webServices{
class GoogleURL{
private static $url;
public function __construct(){}
public function __destruct(){}
public function _get(){
define("serviceURL","http://ggl-shortener.appspot.com/?url=");
$url = serviceURL.urlencode(self::$url);
$request = file_get_contents($url);
$response = (array)json_decode($request);
$result = "<a href='".$response["short_url"]."' target='_blank'>".$response["short_url"]."</a>";
return $result;
}
public function _set($longURL){
self::$url = $longURL;
}
}
}
?>
Kullanımı;
namespace {
$shortURL = new \webServices\GoogleURL();
$shortURL->_set("http://www.hakandamar.com");
print($shortURL->_get()); //http://goo.gl/7aVg
}
Çıktı olarak yeni bir Tab/Pencere ‘de açılan HTML link kontrolü döner. Link’e göre orjinal URL’e ulaşmakta mümkündür.
İyi Çalışmalar.