Welcome to WebmasterWorld Guest from 18.205.176.100

Forum Moderators: coopster & jatar k

i need script to display visitors city and state

php, javascript

     
11:25 pm on Mar 23, 2019 (gmt 0)

New User

joined:Mar 23, 2019
posts: 1
votes: 0


please help me out i need script that I can use in Clickfunnels to display the visitors city and state anywhere I want on the page.
can you please help me guys
3:50 am on Mar 24, 2019 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member tangor is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Nov 29, 2005
posts:10125
votes: 1007


@ameer ... Welcome to Webmasterworld!

Can't help you myself, these kind of tools seem like ... er "magic" and I never bothered. If you are getting reporting with that info, take a look at ordinary scripting/parsing functions to locate the data and then inject it wherever you like.

Note... provide your best effort attempt script and others will help you very quickly to locate any errors in what you are doing. We won't writer it for you. There's no cut and paste.
12:49 pm on Mar 25, 2019 (gmt 0)

New User

joined:Mar 23, 2019
posts: 1
votes: 0


<?php
$ip = $_SERVER['REMOTE_ADDR'];
$api_key = "PUT_YOUR_API_KEY_HERE";
$freegeoipjson = file_get_contents("http://api.ipstack.com/".$ip."?access_key=".$api_key."");
$jsondata = json_decode($freegeoipjson);
$countryfromip = $jsondata->country_name;
$cityfromip = $jsondata->city;
echo "City: ". $cityfromip ."";
echo "<br/>";
echo "Country: ". $countryfromip ."";
?>

the problem is that ipstack free plane doesn't support secure site, I can't find another way to do it, so what do you think I should do?
thanks
5:33 pm on Mar 25, 2019 (gmt 0)

Administrator from US 

WebmasterWorld Administrator not2easy is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Dec 27, 2006
posts:4394
votes: 314


Have you tried using
$freegeoipjson = file_get_contents("//api....
- just removing the http: from the request? If that doesn't do it you might need to search for a different service. "ip-api" is one such service.
3:51 pm on May 28, 2019 (gmt 0)

New User

joined:May 28, 2019
posts:1
votes: 0


Check you Subscription Plan, free plan not support HTTPS Encryption.
4:05 pm on May 28, 2019 (gmt 0)

Senior Member

WebmasterWorld Senior Member Top Contributors Of The Month

joined:Nov 13, 2016
posts:1192
votes: 279

3:23 am on June 24, 2019 (gmt 0)

New User from US 

Top Contributors Of The Month

joined:June 21, 2019
posts: 29
votes: 2


Using curl will solve your issues I do believe....
Set your appropriate vars so you will have to replace the $ip and $api_key with there correct values...

<?php
// plug in your vars here, ip and api key
$ip = "";
$api_key="";

$url ="http://api.ipstack.com/".$ip."?access_key=".$api_key.""

$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_NOBODY, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_MAXREDIRS, 10);

$html = curl_exec($curl);

curl_close($curl);

return $html;
// you could alternately parse $html here and extract the data and just return the vars in an array
?>
3:30 am on June 24, 2019 (gmt 0)

New User from US 

Top Contributors Of The Month

joined:June 21, 2019
posts: 29
votes: 2


Note this is a function.. I omitted putting in that line... sorry... I will repost it
I don't seem to be able to edit my own post and correct typo's


<?php
function retrieve_data()
{
// plug in your vars here, ip and api key or you could pass them in the function call
$ip = "";
$api_key="";

$url ="http://api.ipstack.com/".$ip."?access_key=".$api_key.""

$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_NOBODY, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_MAXREDIRS, 10);

$html = curl_exec($curl);

curl_close($curl);

return $html;
// you could alternately parse $html here and extract the data and just return the vars in an array
}
?>