Google Link Kısaltma ve PHP’de kullanımı

Yakın bir zamanda Google link kısaltma servisi açmıştı ( http://goo.gl ). Buna uygun olarak da PHP’de:

<?php
function ekleGoogle($url)
{
$url = ‘http://ggl-shortener.appspot.com/?url=’.urlencode($url);
$url = file_get_contents($url);
$url = (array) json_decode($url);

return $url;
}
?>

şeklinde fonksiyon oluşturup,

<?php

$kisalacakAdres = ‘http://www.alorak.com/’;

$kisaAdres = ekleGoogle($kisalacakAdres);

print ‘<pre>’;
print_r($kisaAdres);
print ‘</pre>’;

?>

şeklinde de ilgili fonksiyonu kullanabilmekteyiz..

Oca 4th, 2010 | Posted in Programlama
  1. hakan
    May 7th, 2010 at 00:37 | #1

    bu kodları ayrı ayrı kaydedip de mi kullanıcaz? teşekkürler

  2. May 7th, 2010 at 21:31 | #2

    Aynı dosyanın içine de eklenebilir. Üstteki kullanım şekli, alttaki ise kullanımı oluşturan fonksiyon..

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">