我需要通过cURL在PHP登录到某个页面。 我有这样的脚本:会话和通过cURL登录到网站
$cookie_file = 'cookies.txt';
$c = curl_init();
curl_setopt($c, CURLOPT_URL, 'http://www.xxx.pl/index.php?act=ws&sub=login');
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_POSTFIELDS, 'login=aaa&pass=bbb');
curl_setopt($c, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($c, CURLOPT_REFERER, 'http://www.xxx.pl/index.php');
//curl_setopt($c, CURLOPT_HEADER, 1);
curl_setopt($c, CURLOPT_FOLLOWLOCATION, 0);
//curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_COOKIEFILE, dirname(__FILE__) . '/'.$cookie_file);
curl_setopt($c, CURLOPT_COOKIEJAR, dirname(__FILE__) . '/'.$cookie_file);
curl_exec($c);
curl_close($c);
当我运行该脚本登录我(我在DATABSE看到新的日期将在登录),但是当我打开一个网站http://www.xxx.pl/我没有loged。 我认为问题是关于会议。但我不知道如何解决它。
你是什么意思,“当我打开网站”?在浏览器中?未来卷曲电话? –
是的,在浏览器中。首先我运行脚本。接下来,我打开一个网站,我需要被囚禁。 – Karol85