【发布时间】:2016-09-10 01:34:57
【问题描述】:
我在本地主机中收到了验证码,但同一代码服务器无法正常工作。我尝试使用 chmod 完全权限运行我自己的服务器,也在 cookie.txt 文件中提供了完全权限。当我运行完美的本地主机时。我认为,由于 cookie.txt,它不起作用
<?php
header("Content-type: image/jpeg");
function open($url, $cookie = "")
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_COOKIE, 1);
if($cookie != ""){
curl_setopt($ch, CURLOPT_COOKIEJAR, realpath(dirname(__FILE__))."\cookie.txt");
}else{
curl_setopt($ch, CURLOPT_COOKIEFILE, realpath(dirname(__FILE__))."\cookie.txt");
}
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, "http://www.xxxxxx.com/caller/");
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
open("http://www.xxxxxx.com/caller/", 1);
echo open("http://www.xxxxxx.com/security.php?id=".(floor(rand() * 1000) + 1), 0);
?>
你能帮帮我吗?
【问题讨论】:
-
“不起作用”到底是什么意思?
-
我的意思是,它在服务器上不起作用。
-
是的,但无法正常工作,它会着火、冒烟、发出巨大的磨擦声还是出现 Rick Astley 视频?
-
大多数情况下你应该把
-
对不起@Richard,不幸的是,不再。 cookie.txt 不会以任何方式创建一个空白文件,即使它构成 cookie 文件也不会打印。
标签: php curl cookies server localhost