file_get_contents()能否支持页面要求cookie的 目前没遇过但见过一朋友传过header ,并且传了prefer所以,如果是不是动态cookie,应是可以的见第三个参数,并设置流 ,stream看手册 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 建议lz做一个HTTP客户程序比较来的直接http://framework.zend.com/manual/zh/zend.http.html file_get_contents 不支持.但PHP有方法进行COOKIE的提交.你百度一下"curl cookie" 似乎可以,不过我没使用过file_get_contents的后几个参数。在php中,一般来说,发送cookie使用两种方法,一种是使用socket将cookie信息构造在http头里面的方式,另一种是使用curl里面的COOKIEFILE字段来指定cookie文件的位置。用file_get_contents的还真少见,不过我认为curl比它更好用一些。 使用curl里面的COOKIEFILE字段来指定cookie文件的位置。这个比较符合我现在情况, 有这样的例子吗? 可以的,例子如下<?$data = array ( 'msg_author' => 'poster', 'msg_body' => 'gsd958gjsj sdj958fdsj', 'event' => 'comment', 'pid' => '15', 'submit' => 'OK',);function Post($url, $post = null) { $context = array(); if (is_array($post)) { ksort($post); $context['http'] = array ( 'method' => 'POST', 'header' => 'Cookie: 62be229b68f9a8202715cdd8c7092e31=63b33644fd6ed03214ed3887d7ead743; expires=Wed, 28-Jul-2010 13:53:37 GMT;...', 'content' => http_build_query($post, '', '&'), ); } return file_get_contents($url, false, stream_context_create($context)); } echo Post('http://domain/post.php', $data);?> 【在线求助】关于php定时器问题 求一个正则! 时间的匹配问题 问下在showModalDialog直接转向的问题 获取表名 请问在PHP中怎样进行远程文件操作?谢谢 以前唠叨老大写过一个关于分页的文章,搜索不到了,哪位有,烦贴一下,谢谢. 请大家推荐几个用PHP做的网站,谢谢!! 各位高手,请帮忙解决下面的问题。 php里的PHP.exe具体是干什么用的 请问如何批量下载linux下某个目录下的所有文件 给学校保卫处做个网站,大家可有建议的PHP程序?
http://framework.zend.com/manual/zh/zend.http.html
但PHP有方法进行COOKIE的提交.
你百度一下"curl cookie"
<?
$data = array
(
'msg_author' => 'poster',
'msg_body' => 'gsd958gjsj sdj958fdsj',
'event' => 'comment',
'pid' => '15',
'submit' => 'OK',
);function Post($url, $post = null)
{
$context = array();
if (is_array($post))
{
ksort($post);
$context['http'] = array
(
'method' => 'POST',
'header' => 'Cookie: 62be229b68f9a8202715cdd8c7092e31=63b33644fd6ed03214ed3887d7ead743; expires=Wed, 28-Jul-2010 13:53:37 GMT;...',
'content' => http_build_query($post, '', '&'),
);
}
return file_get_contents($url, false, stream_context_create($context));
}
echo Post('http://domain/post.php', $data);
?>