Search code examples
phphtmljsp

How can I get user's country flag on my site


I wanna display user's/visitor's country flag on my site.

I am using different technologies like php,jsp and simple html. So I want a code which by placing on my site, visitors can see and it should run in all platform.

In short I want country detection API. If anybody can help me, I'll be very thankful.


Solution

  • My service, ipdata.co provides an IP Geolocation API on https://api.ipdata.co and serves flags on for example https://ipdata.co/flags/cu.png.

    All you have to do is know your visitors' country's iso code and you can fill it in

    ipdata.co/flags/country-code.png
    

    You can of course get the user's country code by calling https://api.ipdata.co/user-ip.

    Sample embed;

    <img src="https://ipdata.co/flags/us.png" alt="US Flag">
    

    Gives

    US Flag

    Edit

    We now also provide you with the country emoji flag and country emoji unicode.