RES: IP to location / XML
| From: | Jônatas Zechim | Date: | Mon, 02 Feb 2009 18:16:48 +0000 |
| Subject: | RES: IP to location / XML | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-287547@lists.php.net to get a copy of this message | ||
Hi Nathan, i'll try max minds geo ip, that's what i want.
-----Mensagem original-----
De: Nathan Rixham [mailto:nathan@gmail.com]
Enviada em: segunda-feira, 2 de fevereiro de 2009 16:13
Para: php-general@lists.php.net; Jônatas Zechim
Cc: 'PHP General'
Assunto: Re: IP to location / XML
Jônatas Zechim wrote:
> Hi there,
>
> I want do discover the location from a IP, I use this url '
> http://www.onflex.org/geo/xml/ ', that's does a XML
> file, it's ok on my
> browser, but when i try to read this file with php:
>
> $myxml = simplexml_load_file
> ('http://www.onflex.org/geo/xml/');
>
> That's gives a error:
>
> Warning: simplexml_load_file() [function.simplexml-load-file]:
> http://www.onflex.org/geo/xml/:8: parser error : Input is not
> proper
UTF-8,
> indicate encoding ! Bytes: 0xE3 0x6F 0x20 0x50 *****
>
>
> Anyone Who might help me with this?
>
> zechim
>
>
try this:
$file = get_file_contents('http://www.onflex.org/geo/xml/');
$file = utf8_decode($file);
$myxml = simplexml_load_string($file);
the above assumes the problem is because the file is really latin-1
quick note, using the service at onflex.org will always return you're
servers ip address not the end users (as you're calling from server not
clients browser) if this is what you want great, if not then you may
want to try max minds geo ip.
regards!