Created
December 16, 2010 10:32
-
-
Save eabay/743267 to your computer and use it in GitHub Desktop.
Hwm_Geolocation bileşeni örneği
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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