Telize

유료
분류별 Frederic Cambus | 업데이트됨 24 days ago | Location
인기

9.8 / 10

지연 시간

83ms

서비스 수준

100%

Health Check

N/A

모든 토론으로 돌아가기

getting server geoip not visitors

Rapid account: Idan 89
idan89
8 years ago

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 8 years ago

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.

아래에 의견을 추가하고 토론에 참여하세요.

새 댓글을 게시하려면 로그인 / 가입