php 发post包出错 可能问题是 你的 3.php 这个文件的问题,你上面的代码,我在本地运行了,正常的没什么问题。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 建议做简单的 3.php 文件测试。 你可以使用curl来代替socket的方式发送post数据给你个函数,调用它就可以了。function curlrequest($url,$postfield,$proxy=""){ $proxy=trim($proxy); $user_agent ="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"; $ch = curl_init(); // 初始化CURL句柄 if(!empty($proxy)){ curl_setopt ($ch, CURLOPT_PROXY, $proxy);//设置代理服务器 } curl_setopt($ch, CURLOPT_URL, $url); //设置请求的URL //curl_setopt($ch, CURLOPT_FAILONERROR, 1); // 启用时显示HTTP状态码,默认行为是忽略编号小于等于400的HTTP信息 //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);//启用时会将服务器服务器返回的“Location:”放在header中递归的返回给服务器 curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);// 设为TRUE把curl_exec()结果转化为字串,而不是直接输出 curl_setopt($ch, CURLOPT_POST, 1);//启用POST提交 curl_setopt($ch, CURLOPT_POSTFIELDS, $postfield); //设置POST提交的字符串 //curl_setopt($ch, CURLOPT_PORT, 80); //设置端口 curl_setopt($ch, CURLOPT_TIMEOUT, 25); // 超时时间 curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);//HTTP请求User-Agent:头 //curl_setopt($ch,CURLOPT_HEADER,1);//设为TRUE在输出中包含头信息 //$fp = fopen("example_homepage.txt", "w");//输出文件 //curl_setopt($ch, CURLOPT_FILE, $fp);//设置输出文件的位置,值是一个资源类型,默认为STDOUT (浏览器)。 curl_setopt($ch,CURLOPT_HTTPHEADER,array( 'Accept-Language: zh-cn', 'Connection: Keep-Alive', 'Cache-Control: no-cache' ));//设置HTTP头信息 $result = curl_exec($ch); //执行预定义的CURL $info=curl_getinfo($ch); //得到返回信息的特性 //print_r($info); if($info['http_code']=="405"){ echo "bad proxy {$proxy}\n"; //代理出错 exit; } curl_close($ch); return $result; } 提示错误: Fatal error: Maximum execution time of 120 seconds exceeded in D:\Apache Software Foundation\Apache2.2\htdocs\3.php on line 20 错误提示不是明摆着说 在3.php 的20行执行超过了apache 的超时时间 120秒吗? 关于php导出淘宝数据包的颜色尺码的销售属性问题 问个svn的问题(svn提交后,在服务器端checkout文件到生产环境) session失效,很奇怪的失效 求教 用JS验证邮箱格式是否正确 在windows下编写的php程序怎么在freebsd下不能运行了呢? 如何从页面多选框选择出一个数组,没学过php.需要用,在线等 怎样让替换不区分大小写呀?着急!在线等待!!!!!!!!!!!!!!◎ 解决mssql中不能用limit的问题 急,js错误,请帮我看看这个页面. 请教,表的数量对数据库的速度有没有影响? 求一个 rewrite 规则 有没有量网页元素大小的工具?
$proxy=trim($proxy);
$user_agent ="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)";
$ch = curl_init(); // 初始化CURL句柄
if(!empty($proxy)){
curl_setopt ($ch, CURLOPT_PROXY, $proxy);//设置代理服务器
}
curl_setopt($ch, CURLOPT_URL, $url); //设置请求的URL
//curl_setopt($ch, CURLOPT_FAILONERROR, 1); // 启用时显示HTTP状态码,默认行为是忽略编号小于等于400的HTTP信息
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);//启用时会将服务器服务器返回的“Location:”放在header中递归的返回给服务器
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);// 设为TRUE把curl_exec()结果转化为字串,而不是直接输出
curl_setopt($ch, CURLOPT_POST, 1);//启用POST提交
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfield); //设置POST提交的字符串
//curl_setopt($ch, CURLOPT_PORT, 80); //设置端口
curl_setopt($ch, CURLOPT_TIMEOUT, 25); // 超时时间
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);//HTTP请求User-Agent:头
//curl_setopt($ch,CURLOPT_HEADER,1);//设为TRUE在输出中包含头信息
//$fp = fopen("example_homepage.txt", "w");//输出文件
//curl_setopt($ch, CURLOPT_FILE, $fp);//设置输出文件的位置,值是一个资源类型,默认为STDOUT (浏览器)。
curl_setopt($ch,CURLOPT_HTTPHEADER,array(
'Accept-Language: zh-cn',
'Connection: Keep-Alive',
'Cache-Control: no-cache'
));//设置HTTP头信息
$result = curl_exec($ch); //执行预定义的CURL
$info=curl_getinfo($ch); //得到返回信息的特性
//print_r($info);
if($info['http_code']=="405"){
echo "bad proxy {$proxy}\n"; //代理出错
exit;
}
curl_close($ch);
return $result;
}
Fatal error: Maximum execution time of 120 seconds exceeded in D:\Apache Software Foundation\Apache2.2\htdocs\3.php on line 20 错误提示不是明摆着说 在3.php 的20行执行超过了apache 的超时时间 120秒吗?