简体   繁体   English

如何在php中使用ipinfodb API

[英]how to use ipinfodb API in php

I m using the following code to use "ipinfodb.com API". 我正在使用以下代码来使用“ ipinfodb.com API”。 This was written on that website. 这是写在那个网站上的。 I have used correct key 我使用了正确的密钥

and a 'REMOTE_ADDR' but it gives me following result : 和一个“ REMOTE_ADDR”,但它给了我以下结果:


Result : 结果:

Warning: include(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in C:\xampp

\htdocs\temp\index.php on line 18

Warning: include(http://api.ipinfodb.com/ip2locationlite.class.php): failed to open stream: no suitable wrapper 

could be found in C:\xampp\htdocs\temp\index.php on line 18

Warning: include(): Failed opening 'http://api.ipinfodb.com/ip2locationlite.class.php' for inclusion 

(include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\temp\index.php on line 18

Fatal error: Class 'ip2location_lite' not found in C:\xampp\htdocs\temp\index.php on line 21

code used is :::: 使用的代码是::::

<?php
  include('ip2locationlite.class.php');

  //Load the class
  $ipLite = new ip2location_lite;
  $ipLite->setKey('<your_api_key>');

  //Get errors and locations
  $locations = $ipLite->getCity($_SERVER['REMOTE_ADDR']);
  $errors = $ipLite->getError();

  //Getting the result
  echo "<p>\n";
  echo "<strong>First result</strong><br />\n";
  if (!empty($locations) && is_array($locations)) {
  foreach ($locations as $field => $val) {
    echo $field . ' : ' . $val . "<br />\n";
   }
 }
  echo "</p>\n";

  //Show errors
  echo "<p>\n";
  echo "<strong>Dump of all errors</strong><br />\n";
  if (!empty($errors) && is_array($errors)) {
  foreach ($errors as $error) {
    echo var_dump($error) . "<br /><br />\n";
  }
 } else {
   echo "No errors" . "<br />\n";
  }
  echo "</p>\n";
 ?>

Help me as soon as possible. 尽快帮助我。

You are trying to open a php file over http with something like 您正在尝试通过类似以下方式通过http打开php文件

include 'http://somesite.com/somefile.php';

Your version of php is preventing this with security configuration in php.ini. 您的php版本通过php.ini中的安全配置来防止这种情况。 Either change these settings or download the code and install it locally on the server. 更改这些设置或下载代码并将其本地安装在服务器上。

The later is a better idea, since these security settings are in place for good reason. 稍后是一个更好的主意,因为这些安全设置是有充分理由的。 Just look in the manual for further explanation. 只需查看手册以获取更多说明。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM