Find information from the IP address
It may be interesting from an IP address, for the country, city and geographical coordinates.
This is useful for displaying information related to the city, or position the user on a map.
is possible with the project hostip .
Here is a collection of procedures for retrieve these info:
Statements global procedures:
News is an associative array (*, *, *, 4) chains
RecupInfos PROCEDURE (SIP is a chain) s is a chain
/ / We asked hostip. IF NOT
HTTPRequest ("http://api.hostip.info/get_html.php?ip =" SIP + + "& position = true") THEN Error
() ELSE
SRES is a string = HTTPDonneRésultat (HTTPRésultat)
/ / SRES has the form
/ / Country: FRANCE (FR)
/ / City: (Unknown city)
/ / Latitude:
/ / Longitude:
FOR ANY CHAIN s SRES OF SEPARATED BY Attrib (10)
Info [SansEspace (ExtraitChaîne (s, 1 ,":", DepuisDébut))] = ExtraitChaîne (s, 2 ,":", DepuisDébut)
END END PROCEDURE
Country ( )
RETURN Info ["Country"]
PROCEDURE Town () SEND
info ["City"]
PROCEDURE Lattitude () RETURN
info ["Latitude"]
PROCEDURE Longitude () RETURN
Info ["Longitude"]
0 comments:
Post a Comment