我正在尝试使用他们提供的 curl 命令从 IP2Location 下载数据库。我已注册,所以我有一个有效的令牌。他们给出的命令是
curl -o {LOCAL_FILE_NAME} "https://www.ip2location.com/download?token={DOWNLOAD_TOKEN}&file={DATABASE_CODE}"
这是我正在使用的代码,除了我的令牌:
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_URL, "https://www.ip2location.com/download?token={mytoken}&file={DB1LITEBIN}");
$dbfile = curl_exec($curl);
if (curl_errno($curl)) {
echo 'err '.curl_errno($curl);
}
curl_close($curl);
$file = 'db_download.bin';
$mode = 'w';
if (($fp = fopen($file , $mode))) {
$fout = fwrite($fp, $dbfile);
fclose($fp);
}
该脚本运行没有错误,但下载的文件只是他们网站的未找到页面。如果我在浏览器中使用 url,我会找不到相同的页面。有人可以指出我的错误吗?