Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Jak znaleźć lokalizację po IP
PFlorek
post 28.05.2022, 07:59:16
Post #1





Grupa: Zarejestrowani
Postów: 1
Pomógł: 0
Dołączył: 4.09.2019

Ostrzeżenie: (0%)
-----


Jak za pomocą php 7.4 mogę - mając tylko IP zdobyć informację o długości i szerokości geograficznej. - chodzi mi dokładnie o takie coś jak przedstawione na: [xyz] . Chodzi o dane - z lokalizacji IP.
Go to the top of the page
+Quote Post
Tomplus
post 29.05.2022, 21:27:48
Post #2





Grupa: Zarejestrowani
Postów: 1 828
Pomógł: 225
Dołączył: 20.03.2005
Skąd: Będzin

Ostrzeżenie: (0%)
-----


Sam adres IP nie powie ci nic o geolokalizacji. Możesz dowiedzieć się co najwyżej, jakie firmy posiadają pule adresów i na ich podstawie zrobić geolokalizację.
Go to the top of the page
+Quote Post
Atlas
post 21.10.2022, 10:58:45
Post #3





Grupa: Zarejestrowani
Postów: 24
Pomógł: 0
Dołączył: 26.09.2007

Ostrzeżenie: (0%)
-----


Nie chcę reklamować innego forum ale znalazłem takie coś, może Ci się porzydać wink.gif


You could download a free GeoIP database and lookup the IP address locally, or you could use a third party service and perform a remote lookup. This is the simpler option, as it requires no setup, but it does introduce additional latency.

One third party service you could use is mine, http://ipinfo.io. They provide hostname, geolocation, network owner and additional information, eg:

  1. $ curl ipinfo.io/8.8.8.8
  2. {
  3. "ip": "8.8.8.8",
  4. "hostname": "google-public-dns-a.google.com",
  5. "loc": "37.385999999999996,-122.0838",
  6. "org": "AS15169 Google Inc.",
  7. "city": "Mountain View",
  8. "region": "CA",
  9. "country": "US",
  10. "phone": 650
  11. }

Here's a PHP example:
  1.  
  2. $ip = $_SERVER['REMOTE_ADDR'];
  3. $details = json_decode(file_get_contents("http://ipinfo.io/{$ip}/json"));
  4. echo $details->city; // -> "Mountain View"
  5.  


You can also use it client-side. Here's a simple jQuery example:

  1. $.get("https://ipinfo.io/json", function (response) {
  2. $("#ip").html("IP: " + response.ip);
  3. $("#address").html("Location: " + response.city + ", " + response.region);
  4. $("#details").html(JSON.stringify(response, null, 4));
  5. }, "jsonp");
  6. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
  7. <h3>Client side IP geolocation using <a href="http://ipinfo.io">ipinfo.io</a></h3>
  8.  
  9. <hr/>
  10. <div id="ip"></div>
  11. <div id="address"></div>
  12. <hr/>Full response: <pre id="details"></pre>
Go to the top of the page
+Quote Post
trueblue
post 21.10.2022, 11:48:23
Post #4





Grupa: Zarejestrowani
Postów: 6 761
Pomógł: 1822
Dołączył: 11.03.2014

Ostrzeżenie: (0%)
-----


Lokalizacja po IP ma się nijak do rzeczywistości (nie tylko ten serwis). Może z dokładnością co do kraju.


--------------------
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 29.03.2024 - 11:22