我使用以下代码来使用“ipinfodb.com API”。这是写在那个网站上的。我使用了正确的密钥
和'REMOTE_ADDR',但它给了我以下结果:
结果:
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
使用的代码是::::
<?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";
?>
尽快帮助我。
答案 0 :(得分:0)
您正尝试使用类似
的http打开php文件include 'http://somesite.com/somefile.php';
您的php版本通过php.ini中的安全配置阻止了这一点。更改这些设置或下载代码并在服务器上本地安装。
后者是一个更好的主意,因为这些安全设置是有充分理由的。只需查看in the manual即可获得进一步说明。