Forum Moderators: coopster
<?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
?>
<?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
}
?>