Telize

PAID
By Frederic Cambus | Updated vor 14 Tagen | Location
Popularity

9.8 / 10

Latency

83ms

Service Level

100%

Health Check

N/A

Back to All Discussions

getting server geoip not visitors

Rapid account: Idan 89
idan89
hace 8 años

Im not getting the visitors GEOIP information. Instead im getting my server’s ip.
Here is my code.

<?php

if(!isset($_SESSION))
session_start();

require_once ‘lib/unirest-php/src/Unirest.php’;

$key = “MY_KEY”;

response=Unirest\Request::get("https://telizev1.p.mashape.com/geoip?callback=getgeoip",array("XMashapeKey"=>"response = Unirest\Request::get("https://telize-v1.p.mashape.com/geoip?callback=getgeoip", array( "X-Mashape-Key" => "key",
“Accept” => “application/json”
)
);

$body = response>body;response->body; data = json_decode(substr($body, 9,-3));

$_SESSION[‘geoip_country_code’] = $data->country_code;

?>

I need to get the VISITOR’s information and not my server.
Please help me.

Rapid account: Fcambus
fcambus Commented hace 8 años

Hello,

You will need to use the “GeoIP with specific IP” endpoint, and specify the IP address from your visitor as parameter.

Create a variable to store visitor IP :

$remote  = $_SERVER['REMOTE_ADDR'];

And use the snippet provided here replacing {ip_address} placeholder by the content of the $remote variable.

Hope this helps.

Regards.

Join in the discussion - add comment below:

Login / Signup to post new comments