Forum Moderators: coopster

Message Too Old, No Replies

i need script to display visitors city and state

php, javascript

         

ameer

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

5+ Year Member



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

tangor

3:50 am on Mar 24, 2019 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



@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.

ameer

12:49 pm on Mar 25, 2019 (gmt 0)

5+ Year Member



<?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

not2easy

5:33 pm on Mar 25, 2019 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



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.

kratosmx

3:51 pm on May 28, 2019 (gmt 0)

5+ Year Member



Check you Subscription Plan, free plan not support HTTPS Encryption.

Dimitri

4:05 pm on May 28, 2019 (gmt 0)

KnowOneSpecial

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

5+ Year Member Top Contributors Of The Month



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
?>

KnowOneSpecial

3:30 am on Jun 24, 2019 (gmt 0)

5+ Year Member Top Contributors Of The Month



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
}
?>