<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Code snippet ?]]></title><description><![CDATA[<p dir="auto">GeoIP is very interesting to run some checks on visitor location (to deliver customised content).</p>
<p dir="auto">Just wondering if there is a code snippet to extract the country from the results returned.</p>
]]></description><link>https://forum.cloudron.io/topic/5958/code-snippet</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Jul 2026 08:09:46 GMT</lastBuildDate><atom:link href="https://forum.cloudron.io/topic/5958.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 06 Nov 2021 13:41:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Code snippet ? on Sat, 06 Nov 2021 18:11:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/murgero" aria-label="Profile: murgero">@<bdi>murgero</bdi></a> wonderful, thank you !<br />
PHP is great !</p>
]]></description><link>https://forum.cloudron.io/post/38912</link><guid isPermaLink="true">https://forum.cloudron.io/post/38912</guid><dc:creator><![CDATA[timconsidine]]></dc:creator><pubDate>Sat, 06 Nov 2021 18:11:20 GMT</pubDate></item><item><title><![CDATA[Reply to Code snippet ? on Sat, 06 Nov 2021 16:13:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/timconsidine" aria-label="Profile: timconsidine">@<bdi>timconsidine</bdi></a> Since the output from the api is just json encoded you can take the output in a variable and parse it:</p>
<p dir="auto">this example is PHP of course:</p>
<pre><code>&lt;?php

//google.com IP for mid-west US:
$ip = "142.251.32.14";

//Get string from API URL then convert the json output to PHP obj
$geoip = file_get_contents("https://geoip.example.com/json?ip=$ip");
$geoip = json_decode($geoip, true);

//Output Country in string:
echo "The registered country of the IP $ip is ".$geoip['registered_country']['names']['en']."\r\n";
echo "Also, you can grab the country name via ['country']['names']['en']: ".$geoip['country']['names']['en']."\r\n";
?&gt;
</code></pre>
]]></description><link>https://forum.cloudron.io/post/38904</link><guid isPermaLink="true">https://forum.cloudron.io/post/38904</guid><dc:creator><![CDATA[murgero]]></dc:creator><pubDate>Sat, 06 Nov 2021 16:13:24 GMT</pubDate></item></channel></rss>