/**
 * @param $ip 待查询的ip
 * @return mixed
 */
function getIpAddressInfo($ip)
{
    $ipurl = 'http://api.ip138.com/query/?ip=' . $ip . '&datatype=txt';
    $ipheader = array('token:注册的token');
    $ipch = curl_init();
    curl_setopt($ipch, CURLOPT_URL, $ipurl);
    curl_setopt($ipch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
    curl_setopt($ipch, CURLOPT_HTTPHEADER, $ipheader);
    curl_setopt($ipch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ipch, CURLOPT_CONNECTTIMEOUT, 3);
    $iphandles = curl_exec($ipch);
    curl_close($ipch);
    return $iphandles;
}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-07
  • 2021-11-28
  • 2022-02-07
  • 2022-01-11
  • 2021-05-05
猜你喜欢
  • 2021-12-31
  • 2022-12-23
  • 2022-01-02
  • 2021-12-31
  • 2022-12-23
相关资源
相似解决方案