<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Api on Ulis Notizen</title>
    <link>https://wolf-u.li/tag/api/</link>
    <description>Recent content in Api on Ulis Notizen</description>
    <generator>Hugo</generator>
    <language>de</language>
    <copyright>Copyright 2006-CURRENTYEAR Uli Wolf - All rights reserved</copyright>
    <lastBuildDate>Thu, 25 Feb 2016 09:32:24 +2500</lastBuildDate>
    <atom:link href="https://wolf-u.li/tag/api/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>FHEM: Fahrzeiten mit Verkehr mittels Google Maps API anzeigen</title>
      
      
      <link>https://wolf-u.li/fhem-fahrzeiten-mit-verkehr-mittels-google-maps-api-anzeigen/</link>
      <pubDate>Sat, 09 Jan 2016 13:29:55 +0900</pubDate>
      <guid>https://wolf-u.li/fhem-fahrzeiten-mit-verkehr-mittels-google-maps-api-anzeigen/</guid>
      <description>&lt;p&gt;Inspiriert von einem Artikel, den ich &lt;link rel=dns-prefetch href=//www.juergenstechnikwelt.de /&gt; &lt;a href=&#34;http://www.juergenstechnikwelt.de/smarthome-2/smarthome-mit-fhem-fahrzeiten-mit-verkehr-mittels-google-maps-api-anzeigen/&#34;
    title=&#34;hier&#34; 
     target=&#34;_blank&#34; rel=&#34;nofollow noopener noreferrer&#34; &gt;
  hier&amp;nbsp;&lt;svg xmlns=&#34;http://www.w3.org/2000/svg&#34; class=&#34;icon&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34; viewBox=&#34;0 -128 512 640&#34;&gt;
    &lt;path d=&#34;M384 320c-17.67 0-32 14.33-32 32v96H64V160h96c17.67 0 32-14.32 32-32s-14.33-32-32-32L64 96c-35.35 0-64 28.65-64 64V448c0 35.34 28.65 64 64 64h288c35.35 0 64-28.66 64-64v-96C416 334.3 401.7 320 384 320zM488 0H352c-12.94 0-24.62 7.797-29.56 19.75c-4.969 11.97-2.219 25.72 6.938 34.88L370.8 96L169.4 297.4c-12.5 12.5-12.5 32.75 0 45.25C175.6 348.9 183.8 352 192 352s16.38-3.125 22.62-9.375L416 141.3l41.38 41.38c9.156 9.141 22.88 11.84 34.88 6.938C504.2 184.6 512 172.9 512 160V24C512 10.74 501.3 0 488 0z&#34;/&gt;
  &lt;/svg&gt;&lt;/a&gt; gefunden habe, habe ich mir ebenfalls mal HTTPMOD mit der Google Maps Api angesehen. Die Grundzüge hat der Author schon erläutert - ich mache hier lediglich eine Vereinfachung und Update.&lt;/p&gt;</description>
      
         <content:encoded><![CDATA[<p>Inspiriert von einem Artikel, den ich <link rel=dns-prefetch href=//www.juergenstechnikwelt.de /> <a href="http://www.juergenstechnikwelt.de/smarthome-2/smarthome-mit-fhem-fahrzeiten-mit-verkehr-mittels-google-maps-api-anzeigen/"
    title="hier" 
     target="_blank" rel="nofollow noopener noreferrer" >
  hier&nbsp;<svg xmlns="http://www.w3.org/2000/svg" class="icon" aria-hidden="true" focusable="false" viewBox="0 -128 512 640">
    <path d="M384 320c-17.67 0-32 14.33-32 32v96H64V160h96c17.67 0 32-14.32 32-32s-14.33-32-32-32L64 96c-35.35 0-64 28.65-64 64V448c0 35.34 28.65 64 64 64h288c35.35 0 64-28.66 64-64v-96C416 334.3 401.7 320 384 320zM488 0H352c-12.94 0-24.62 7.797-29.56 19.75c-4.969 11.97-2.219 25.72 6.938 34.88L370.8 96L169.4 297.4c-12.5 12.5-12.5 32.75 0 45.25C175.6 348.9 183.8 352 192 352s16.38-3.125 22.62-9.375L416 141.3l41.38 41.38c9.156 9.141 22.88 11.84 34.88 6.938C504.2 184.6 512 172.9 512 160V24C512 10.74 501.3 0 488 0z"/>
  </svg></a> gefunden habe, habe ich mir ebenfalls mal HTTPMOD mit der Google Maps Api angesehen. Die Grundzüge hat der Author schon erläutert - ich mache hier lediglich eine Vereinfachung und Update.</p>
<p><strong>Achtung: Dieser Beitrag benötigt eine noch experimentelle Version von HTTPMOD aus diesem <link rel=dns-prefetch href=//forum.fhem.de /> <a href="http://forum.fhem.de/index.php/topic,45176.msg369686.html#msg369686#msg369686"
    title="Forumsthread" 
     target="_blank" rel="nofollow noopener noreferrer" >
  Forumsthread&nbsp;<svg xmlns="http://www.w3.org/2000/svg" class="icon" aria-hidden="true" focusable="false" viewBox="0 -128 512 640">
    <path d="M384 320c-17.67 0-32 14.33-32 32v96H64V160h96c17.67 0 32-14.32 32-32s-14.33-32-32-32L64 96c-35.35 0-64 28.65-64 64V448c0 35.34 28.65 64 64 64h288c35.35 0 64-28.66 64-64v-96C416 334.3 401.7 320 384 320zM488 0H352c-12.94 0-24.62 7.797-29.56 19.75c-4.969 11.97-2.219 25.72 6.938 34.88L370.8 96L169.4 297.4c-12.5 12.5-12.5 32.75 0 45.25C175.6 348.9 183.8 352 192 352s16.38-3.125 22.62-9.375L416 141.3l41.38 41.38c9.156 9.141 22.88 11.84 34.88 6.938C504.2 184.6 512 172.9 512 160V24C512 10.74 501.3 0 488 0z"/>
  </svg></a></strong></p>
<p>Los gehts mit der Erstellung des API-Keys via <link rel=dns-prefetch href=//console.developers.google.com /> <a href="https://console.developers.google.com/start?hl=de"
    title="Google Developer Console" 
     target="_blank" rel="nofollow noopener noreferrer" >
  Google Developer Console&nbsp;<svg xmlns="http://www.w3.org/2000/svg" class="icon" aria-hidden="true" focusable="false" viewBox="0 -128 512 640">
    <path d="M384 320c-17.67 0-32 14.33-32 32v96H64V160h96c17.67 0 32-14.32 32-32s-14.33-32-32-32L64 96c-35.35 0-64 28.65-64 64V448c0 35.34 28.65 64 64 64h288c35.35 0 64-28.66 64-64v-96C416 334.3 401.7 320 384 320zM488 0H352c-12.94 0-24.62 7.797-29.56 19.75c-4.969 11.97-2.219 25.72 6.938 34.88L370.8 96L169.4 297.4c-12.5 12.5-12.5 32.75 0 45.25C175.6 348.9 183.8 352 192 352s16.38-3.125 22.62-9.375L416 141.3l41.38 41.38c9.156 9.141 22.88 11.84 34.88 6.938C504.2 184.6 512 172.9 512 160V24C512 10.74 501.3 0 488 0z"/>
  </svg></a>. Dort auf &ldquo;APIs aktivieren und verwalten&rdquo;:
<a href="/upload/2016/01/5535-FHEM-MAPS-API-01.webp"
    title="" 
   >
  <img src="/upload/2016/01/5535-FHEM-MAPS-API-01.webp" alt="5535-FHEM-MAPS-API-01" loading="lazy"></a>
Dann ein neues Projekt erstellen und einen Projektnamen vergeben (z.B. <code>fhem-maps-api</code>):
<a href="/upload/2016/01/5535-FHEM-MAPS-API-02.webp"
    title="" 
   >
  <img src="/upload/2016/01/5535-FHEM-MAPS-API-02.webp" alt="5535-FHEM-MAPS-API-02" loading="lazy"></a>
Dann suche in der nächsten Übersicht nach &ldquo;<code>Google Maps Distance</code>&rdquo; und nimm die &ldquo;Google Maps Distance Matrix API&rdquo;:
<a href="/upload/2016/01/5535-FHEM-MAPS-API-03.webp"
    title="" 
   >
  <img src="/upload/2016/01/5535-FHEM-MAPS-API-03.webp" alt="5535-FHEM-MAPS-API-03" loading="lazy"></a>
Aktiviere diese:
<a href="/upload/2016/01/5535-FHEM-MAPS-API-04.webp"
    title="" 
   >
  <img src="/upload/2016/01/5535-FHEM-MAPS-API-04.webp" alt="5535-FHEM-MAPS-API-04" loading="lazy"></a>
Klicke dann links auf &ldquo;Zugangsdaten&rdquo;:
<a href="/upload/2016/01/5535-FHEM-MAPS-API-05.webp"
    title="" 
   >
  <img src="/upload/2016/01/5535-FHEM-MAPS-API-05.webp" alt="5535-FHEM-MAPS-API-05" loading="lazy"></a>
Wähle &ldquo;Browser-Schlüssel&rdquo;:
<a href="/upload/2016/01/5535-FHEM-MAPS-API-06.webp"
    title="" 
   >
  <img src="/upload/2016/01/5535-FHEM-MAPS-API-06.webp" alt="5535-FHEM-MAPS-API-06" loading="lazy"></a>
Nimm einen beliebigen Namen, welcher für dich Aussagekraft hat.
<a href="/upload/2016/01/5535-FHEM-MAPS-API-07.webp"
    title="" 
   >
  <img src="/upload/2016/01/5535-FHEM-MAPS-API-07.webp" alt="5535-FHEM-MAPS-API-07" loading="lazy"></a>
Nun ist dein API-Schlüssel erstellt. Diesen musst du kopieren.
<a href="/upload/2016/01/5535-FHEM-MAPS-API-08.webp"
    title="" 
   >
  <img src="/upload/2016/01/5535-FHEM-MAPS-API-08.webp" alt="5535-FHEM-MAPS-API-08" loading="lazy"></a></p>
<p>Dann gehts in FHEM. Im untenstehenden Code muss YOURAPIKEY gegen den soeben erstellten API Key getauscht werden, ebenso natürlich dein Abfahrtsort (ORIGIN) und ZIEL (DESTINATION). Um letztere herauszufinden, würde ich eine Google Maps Suche machen und dann das Feld jeweils herauskopieren. Leerzeichen sollten durch %20 ersetzt werden, also beispielsweise wird aus: <code>Robert-Schuman-Straße 8, 68519 Viernheim</code> dann <code>Robert-Schuman-Straße%208,%2068519%20Viernheim</code>. Die definition des Devices folgt wie immer meiner <a href="/5530/fhem-meine-namenskonvention-als-starthilfe-fuer-einsteiger/"
    title="Namenskonvention" 
   >
  Namenskonvention</a>:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt"> 1
</span><span class="lnt"> 2
</span><span class="lnt"> 3
</span><span class="lnt"> 4
</span><span class="lnt"> 5
</span><span class="lnt"> 6
</span><span class="lnt"> 7
</span><span class="lnt"> 8
</span><span class="lnt"> 9
</span><span class="lnt">10
</span><span class="lnt">11
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-perl" data-lang="perl"><span class="line"><span class="cl"><span class="n">define</span> <span class="n">INF_HTM_FAHRZEIT_HOME_WORK</span> <span class="n">HTTPMOD</span> <span class="n">https:</span><span class="sr">//m</span><span class="n">aps</span><span class="o">.</span><span class="n">googleapis</span><span class="o">.</span><span class="n">com</span><span class="sr">/maps/</span><span class="n">api</span><span class="sr">/distancematrix/</span><span class="n">json</span><span class="p">?</span><span class="n">origins</span><span class="o">=</span><span class="n">ORIGIN</span><span class="o">&amp;</span><span class="n">destinations</span><span class="o">=</span><span class="n">DESTINATION</span><span class="o">&amp;</span><span class="n">mode</span><span class="o">=</span><span class="n">driving</span><span class="o">&amp;</span><span class="n">language</span><span class="o">=</span><span class="n">de</span><span class="o">-</span><span class="n">DE</span><span class="o">&amp;</span><span class="n">departure_time</span><span class="o">=</span><span class="n">now</span><span class="o">&amp;</span><span class="n">key</span><span class="o">=</span><span class="n">YOURAPIKEY</span> <span class="mi">3600</span>
</span></span><span class="line"><span class="cl"><span class="n">attr</span> <span class="n">INF_HTM_FAHRZEIT_HOME_WORK</span> <span class="n">reading01Name</span> <span class="n">standard</span>
</span></span><span class="line"><span class="cl"><span class="n">attr</span> <span class="n">INF_HTM_FAHRZEIT_HOME_WORK</span> <span class="n">reading01JSON</span> <span class="n">rows_01_elements_01_duration_value</span>
</span></span><span class="line"><span class="cl"><span class="n">attr</span> <span class="n">INF_HTM_FAHRZEIT_HOME_WORK</span> <span class="n">reading01Expr</span> <span class="n">strftime</span><span class="p">(</span><span class="s">&#34;%T&#34;</span><span class="p">,</span> <span class="nb">gmtime</span> <span class="nv">$val</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">attr</span> <span class="n">INF_HTM_FAHRZEIT_HOME_WORK</span> <span class="n">reading02Name</span> <span class="n">traffic</span>
</span></span><span class="line"><span class="cl"><span class="n">attr</span> <span class="n">INF_HTM_FAHRZEIT_HOME_WORK</span> <span class="n">reading02JSON</span> <span class="n">rows_01_elements_01_duration_in_traffic_value</span>
</span></span><span class="line"><span class="cl"><span class="n">attr</span> <span class="n">INF_HTM_FAHRZEIT_HOME_WORK</span> <span class="n">reading02Expr</span> <span class="n">strftime</span><span class="p">(</span><span class="s">&#34;%T&#34;</span><span class="p">,</span> <span class="nb">gmtime</span> <span class="nv">$val</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">attr</span> <span class="n">INF_HTM_FAHRZEIT_HOME_WORK</span> <span class="n">reading03Name</span> <span class="n">distance</span>
</span></span><span class="line"><span class="cl"><span class="n">attr</span> <span class="n">INF_HTM_FAHRZEIT_HOME_WORK</span> <span class="n">reading03JSON</span> <span class="n">rows_01_elements_01_distance_value</span>
</span></span><span class="line"><span class="cl"><span class="n">attr</span> <span class="n">INF_HTM_FAHRZEIT_HOME_WORK</span> <span class="n">reading03Expr</span> <span class="nb">sprintf</span><span class="p">(</span><span class="s">&#34;%.1f&#34;</span><span class="p">,</span> <span class="nv">$val</span><span class="o">/</span><span class="mi">1000</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">attr</span> <span class="n">INF_HTM_FAHRZEIT_HOME_WORK</span> <span class="n">stateFormat</span> <span class="n">Normal:standard</span> <span class="n">Aktuell:traffic</span> <span class="p">(</span><span class="n">distance</span> <span class="n">km</span><span class="p">)</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>Vielen Dank nochmals an <link rel=dns-prefetch href=//www.juergenstechnikwelt.de /> <a href="http://www.juergenstechnikwelt.de/smarthome-2/smarthome-mit-fhem-fahrzeiten-mit-verkehr-mittels-google-maps-api-anzeigen/"
    title="Jürgen für die Idee" 
     target="_blank" rel="nofollow noopener noreferrer" >
  Jürgen für die Idee&nbsp;<svg xmlns="http://www.w3.org/2000/svg" class="icon" aria-hidden="true" focusable="false" viewBox="0 -128 512 640">
    <path d="M384 320c-17.67 0-32 14.33-32 32v96H64V160h96c17.67 0 32-14.32 32-32s-14.33-32-32-32L64 96c-35.35 0-64 28.65-64 64V448c0 35.34 28.65 64 64 64h288c35.35 0 64-28.66 64-64v-96C416 334.3 401.7 320 384 320zM488 0H352c-12.94 0-24.62 7.797-29.56 19.75c-4.969 11.97-2.219 25.72 6.938 34.88L370.8 96L169.4 297.4c-12.5 12.5-12.5 32.75 0 45.25C175.6 348.9 183.8 352 192 352s16.38-3.125 22.62-9.375L416 141.3l41.38 41.38c9.156 9.141 22.88 11.84 34.88 6.938C504.2 184.6 512 172.9 512 160V24C512 10.74 501.3 0 488 0z"/>
  </svg></a> - sehr cool :)</p>
]]></content:encoded>
    </item>
    <item>
      <title>Geolocation API für IP-Adressen</title>
      
      
      <link>https://wolf-u.li/geolocation-api-fuer-ip-adressen/</link>
      <pubDate>Sat, 16 May 2009 11:33:33 +1600</pubDate>
      <guid>https://wolf-u.li/geolocation-api-fuer-ip-adressen/</guid>
      <description>&lt;p&gt;Heute habe ich eine Möglichkeit gesucht, aus einer IP-Adresse eine möglichst genaue Ortsangabe zu bekommen. Da ich diese Funktionalität nur selten benötige, wollte ich keine Datenbank auf meinem Server installieren, welche mir dies bereitstellen könnte. Aus diesem Grund habe ich mich nach API&amp;rsquo;s umgesehen, welche dies für mich erledigen können.&lt;/p&gt;
&lt;p&gt;Es gibt mehrere Möglichkeiten in diesem Sektor. Das häufig beworbene &lt;link rel=dns-prefetch href=//sourceforge.net /&gt; &lt;a href=&#34;http://sourceforge.net/projects/geoip/&#34;
    title=&#34;Sourceforge-Projekt MaxWind GeoIP&#34; 
     target=&#34;_blank&#34; rel=&#34;nofollow noopener noreferrer&#34; &gt;
  Sourceforge-Projekt MaxWind GeoIP&amp;nbsp;&lt;svg xmlns=&#34;http://www.w3.org/2000/svg&#34; class=&#34;icon&#34; aria-hidden=&#34;true&#34; focusable=&#34;false&#34; viewBox=&#34;0 -128 512 640&#34;&gt;
    &lt;path d=&#34;M384 320c-17.67 0-32 14.33-32 32v96H64V160h96c17.67 0 32-14.32 32-32s-14.33-32-32-32L64 96c-35.35 0-64 28.65-64 64V448c0 35.34 28.65 64 64 64h288c35.35 0 64-28.66 64-64v-96C416 334.3 401.7 320 384 320zM488 0H352c-12.94 0-24.62 7.797-29.56 19.75c-4.969 11.97-2.219 25.72 6.938 34.88L370.8 96L169.4 297.4c-12.5 12.5-12.5 32.75 0 45.25C175.6 348.9 183.8 352 192 352s16.38-3.125 22.62-9.375L416 141.3l41.38 41.38c9.156 9.141 22.88 11.84 34.88 6.938C504.2 184.6 512 172.9 512 160V24C512 10.74 501.3 0 488 0z&#34;/&gt;
  &lt;/svg&gt;&lt;/a&gt; gefiel mir prinzipiell nicht schlecht, erforderte aber entweder die Installation der IP-Daten auf einem Server oder konnte nur wenige kostenlose Anfragen pro Tag verarbeiten.&lt;/p&gt;</description>
      
         <content:encoded><![CDATA[<p>Heute habe ich eine Möglichkeit gesucht, aus einer IP-Adresse eine möglichst genaue Ortsangabe zu bekommen. Da ich diese Funktionalität nur selten benötige, wollte ich keine Datenbank auf meinem Server installieren, welche mir dies bereitstellen könnte. Aus diesem Grund habe ich mich nach API&rsquo;s umgesehen, welche dies für mich erledigen können.</p>
<p>Es gibt mehrere Möglichkeiten in diesem Sektor. Das häufig beworbene <link rel=dns-prefetch href=//sourceforge.net /> <a href="http://sourceforge.net/projects/geoip/"
    title="Sourceforge-Projekt MaxWind GeoIP" 
     target="_blank" rel="nofollow noopener noreferrer" >
  Sourceforge-Projekt MaxWind GeoIP&nbsp;<svg xmlns="http://www.w3.org/2000/svg" class="icon" aria-hidden="true" focusable="false" viewBox="0 -128 512 640">
    <path d="M384 320c-17.67 0-32 14.33-32 32v96H64V160h96c17.67 0 32-14.32 32-32s-14.33-32-32-32L64 96c-35.35 0-64 28.65-64 64V448c0 35.34 28.65 64 64 64h288c35.35 0 64-28.66 64-64v-96C416 334.3 401.7 320 384 320zM488 0H352c-12.94 0-24.62 7.797-29.56 19.75c-4.969 11.97-2.219 25.72 6.938 34.88L370.8 96L169.4 297.4c-12.5 12.5-12.5 32.75 0 45.25C175.6 348.9 183.8 352 192 352s16.38-3.125 22.62-9.375L416 141.3l41.38 41.38c9.156 9.141 22.88 11.84 34.88 6.938C504.2 184.6 512 172.9 512 160V24C512 10.74 501.3 0 488 0z"/>
  </svg></a> gefiel mir prinzipiell nicht schlecht, erforderte aber entweder die Installation der IP-Daten auf einem Server oder konnte nur wenige kostenlose Anfragen pro Tag verarbeiten.</p>
<p>Eine weitere Wahl war <link rel=dns-prefetch href=//www.hostip.info /> <a href="http://www.hostip.info/"
    title="HostIP" 
     target="_blank" rel="nofollow noopener noreferrer" >
  HostIP&nbsp;<svg xmlns="http://www.w3.org/2000/svg" class="icon" aria-hidden="true" focusable="false" viewBox="0 -128 512 640">
    <path d="M384 320c-17.67 0-32 14.33-32 32v96H64V160h96c17.67 0 32-14.32 32-32s-14.33-32-32-32L64 96c-35.35 0-64 28.65-64 64V448c0 35.34 28.65 64 64 64h288c35.35 0 64-28.66 64-64v-96C416 334.3 401.7 320 384 320zM488 0H352c-12.94 0-24.62 7.797-29.56 19.75c-4.969 11.97-2.219 25.72 6.938 34.88L370.8 96L169.4 297.4c-12.5 12.5-12.5 32.75 0 45.25C175.6 348.9 183.8 352 192 352s16.38-3.125 22.62-9.375L416 141.3l41.38 41.38c9.156 9.141 22.88 11.84 34.88 6.938C504.2 184.6 512 172.9 512 160V24C512 10.74 501.3 0 488 0z"/>
  </svg></a>, welche mir leider für meine momentane IP schon keine Daten liefern konnten. Mehr oder minder also nicht brauchbar.</p>
<p>Ich habe mich letztendlich für <link rel=dns-prefetch href=//ipinfodb.com /> <a href="http://ipinfodb.com/ip_location_api.php"
    title="IPInfoDB" 
     target="_blank" rel="nofollow noopener noreferrer" >
  IPInfoDB&nbsp;<svg xmlns="http://www.w3.org/2000/svg" class="icon" aria-hidden="true" focusable="false" viewBox="0 -128 512 640">
    <path d="M384 320c-17.67 0-32 14.33-32 32v96H64V160h96c17.67 0 32-14.32 32-32s-14.33-32-32-32L64 96c-35.35 0-64 28.65-64 64V448c0 35.34 28.65 64 64 64h288c35.35 0 64-28.66 64-64v-96C416 334.3 401.7 320 384 320zM488 0H352c-12.94 0-24.62 7.797-29.56 19.75c-4.969 11.97-2.219 25.72 6.938 34.88L370.8 96L169.4 297.4c-12.5 12.5-12.5 32.75 0 45.25C175.6 348.9 183.8 352 192 352s16.38-3.125 22.62-9.375L416 141.3l41.38 41.38c9.156 9.141 22.88 11.84 34.88 6.938C504.2 184.6 512 172.9 512 160V24C512 10.74 501.3 0 488 0z"/>
  </svg></a> entschieden, da diese eine einfache und relativ genaue API im XML oder JSON-Format bereitstellen konnten.</p>
<p>Ein schnelles Beispiel in curl und PHP zur Lokalisierung der IP mittels des Städtenamens:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt"> 1
</span><span class="lnt"> 2
</span><span class="lnt"> 3
</span><span class="lnt"> 4
</span><span class="lnt"> 5
</span><span class="lnt"> 6
</span><span class="lnt"> 7
</span><span class="lnt"> 8
</span><span class="lnt"> 9
</span><span class="lnt">10
</span><span class="lnt">11
</span><span class="lnt">12
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-php" data-lang="php"><span class="line"><span class="cl"><span class="k">function</span> <span class="nf">locateCityByIp</span><span class="p">(</span><span class="nv">$ip</span><span class="p">){</span>
</span></span><span class="line"><span class="cl"> <span class="nv">$ch</span> <span class="o">=</span> <span class="nx">curl_init</span><span class="p">();</span>
</span></span><span class="line"><span class="cl"> <span class="nx">curl_setopt</span><span class="p">(</span><span class="nv">$ch</span><span class="p">,</span> <span class="nx">CURLOPT_URL</span><span class="p">,</span> <span class="s1">&#39;http://ipinfodb.com/ip_query.php?ip=&#39;</span> <span class="o">.</span> <span class="nv">$ip</span> <span class="o">.</span> <span class="s2">&#34;&amp;output=xml&#34;</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="nx">curl_setopt</span><span class="p">(</span><span class="nv">$ch</span><span class="p">,</span> <span class="nx">CURLOPT_CONNECTTIMEOUT</span><span class="p">,</span> <span class="mi">4</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="nx">curl_setopt</span><span class="p">(</span><span class="nv">$ch</span><span class="p">,</span> <span class="nx">CURLOPT_RETURNTRANSFER</span><span class="p">,</span> <span class="k">TRUE</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="nv">$ipdata</span> <span class="o">=</span> <span class="nx">simplexml_load_string</span><span class="p">(</span><span class="nx">curl_exec</span><span class="p">(</span><span class="nv">$ch</span><span class="p">));</span>
</span></span><span class="line"><span class="cl"> <span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="k">empty</span><span class="p">(</span><span class="nv">$ipdata</span><span class="o">-&gt;</span><span class="na">City</span><span class="p">))</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">return</span> <span class="nv">$ipdata</span><span class="o">-&gt;</span><span class="na">City</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">return</span> <span class="s1">&#39;&#39;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre></td></tr></table>
</div>
</div>]]></content:encoded>
    </item>
  </channel>
</rss>
