Skip to content

Instantly share code, notes, and snippets.

@eabay
Created December 16, 2010 10:32
Show Gist options
  • Save eabay/743267 to your computer and use it in GitHub Desktop.
Save eabay/743267 to your computer and use it in GitHub Desktop.
Hwm_Geolocation bileşeni örneği
<?php
// HWM Framework Zend Autoloader'ını kullandığı için öncelikle
// Autoloader'a Hwm namespace'inin varlığını bildirmeliyiz.
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance()->registerNamespace('Hwm');
// Varsayılan servis MaxMind olduğu için servis sağlayıcı
// olarak Geobytes'ı kullanacağımızı da belirtmemiz gerekiyor.
try {
$geolocation = Hwm_Geolocation::lookup('IP ADRESİ', array('provider' => 'geobytes'));
} catch (Hwm_Geolocation_Provider_Geobytes_Exception $e) {
//...
}
// Bilgiler için uygun metodları çağırıyoruz.
echo 'Ülke Kodu: ' . $geolocation->getCountryCode();
echo 'Ülke Adı: ' . $geolocation->getCountryName();
echo 'Şehir: ' . $geolocation->getCityName();
echo 'Enlem: ' . $geolocation->getLatitude();
echo 'Boylam: ' . $geolocation->getLongitude();
// Dilerseniz servisten dönen cevabı işlenmemiş olarak görüntüleyebilirsiniz.
echo 'Ham Veri: ' . $geolocation->getRawResult();
<?php
//.........
try {
$geolocation = Hwm_Geolocation::lookup('IP ADRESİ', array(
'provider' => 'maxmind',
'license' => 'MAXMIND WEBSERVICE LİSANS KODUNUZ'
));
} catch (Hwm_Geolocation_Provider_Maxmind_Exception $e) {
//...
}
echo 'Ülke Adı: ' . $geolocation->getCountryName();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment