Geolocate by Public IP

Revision for “Geolocate by Public IP” created on 4 février 2016 à 13 h 30 min

Titre
Geolocate by Public IP
Contenu
Pour géolocaliser une IP public, nous allons utiliser l'api du site http://ip-api.com/. Pour utiliser cette API, l'outil "curl" va nous être utile == Installation == <pre> aptitude install curl </pre> == Utilisation == Nous avons le choix entre plusieurs formats de sortie lors d'une requête à l'API === XML === <pre> curl -XGET http://ip-api.com/xml/208.80.152.201 </pre> <pre> <?xml version="1.0" encoding="UTF-8"?> <query> <status>success</status> <country><![CDATA[United States]]></country> <countryCode><![CDATA[US]]></countryCode> <region><![CDATA[CA]]></region> <regionName><![CDATA[California]]></regionName> <city><![CDATA[San Francisco]]></city> <zip><![CDATA[94105]]></zip> <lat><![CDATA[37.7898]]></lat> <lon><![CDATA[-122.3942]]></lon> <timezone><![CDATA[America/Los_Angeles]]></timezone> <isp><![CDATA[Wikimedia Foundation]]></isp> <org><![CDATA[Wikimedia Foundation]]></org> <as><![CDATA[AS14907 Wikimedia US network]]></as> <query><![CDATA[208.80.152.201]]></query> </query> </pre> === JSON === <pre> curl -XGET http://ip-api.com/json/208.80.152.201 </pre> <pre> {"status":"success","country":"United States","countryCode":"US","region":"CA", "regionName":"California","city":"San Francisco","zip":"94105","lat":"37.7898", "lon":"-122.3942","timezone":"America\/Los_Angeles","isp":"Wikimedia Foundation", "org":"Wikimedia Foundation","as":"AS14907 Wikimedia US network","query":"208.80.152.201"} </pre> === CSV === <pre> curl -XGET http://ip-api.com/csv/208.80.152.201 </pre> <pre> success,"United States",US,CA,California,"San Francisco",94105,37.7898,-122.3942,America/Los_Angeles,"Wikimedia Foundation","Wikimedia Foundation","AS14907 Wikimedia US network",208.80.152.201 </pre> === Séparé par une ligne === <pre> curl -XGET http://ip-api.com/line/208.80.152.201 </pre> <pre> success United States US CA California San Francisco 94105 37.7898 -122.3942 America/Los_Angeles Wikimedia Foundation Wikimedia Foundation AS14907 Wikimedia US network </pre> === Sérialisé PHP === <pre> curl -XGET http://ip-api.com/php/208.80.152.201 </pre> <pre> a:14:{s:6:"status";s:7:"success";s:7:"country";s:13:"United States";s:11:"countryCode";s:2:"US";s:6:"region";s:2:"CA";s:10:"regionName";s:10:"California";s:4:"city"; s:13:"San Francisco";s:3:"zip";s:5:"94105";s:3:"lat";s:7:"37.7898";s:3:"lon";s:9:"-122.3942";s:8:"timezone";s:19:"America/Los_Angeles";s:3:"isp";s:20:"Wikimedia Foundation"; s:3:"org";s:20:"Wikimedia Foundation";s:2:"as";s:28:"AS14907 Wikimedia US network";s:5:"query";s:14:"208.80.152.201";} </pre>
Extrait


OldNewDate CreatedAuthorActions
4 février 2016 à 13 h 30 min Anthony Magnini