<?php
$test=post("http://127.0.0.1:81/lol/t.php",array("t=123"));
//$test=iconv("gb2312//IGNORE", "utf-8" , $test);
echo($test);function post($url, $data)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/xml', 'Content-Type: application/xml'));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$response = curl_exec($ch);
curl_close($ch); return $response;
}
?>提示这个:
Request Entity Too LargeThe requested resource
/lol/t.php
does not allow request data with POST requests, or the amount of data provided in the request exceeds the capacity limit.谢谢了.
$test=post("http://127.0.0.1:81/lol/t.php",array("t=123"));
//$test=iconv("gb2312//IGNORE", "utf-8" , $test);
echo($test);function post($url, $data)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/xml', 'Content-Type: application/xml'));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$response = curl_exec($ch);
curl_close($ch); return $response;
}
?>提示这个:
Request Entity Too LargeThe requested resource
/lol/t.php
does not allow request data with POST requests, or the amount of data provided in the request exceeds the capacity limit.谢谢了.
$URL="http://xxx/Service.asmx/getFormatValuesV2?";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"$URL");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "u=demo&sc=SZX&ec=KHN&sd=2011-10-19&ed=2011-10-29&showround=&f=&t=");
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
$output = curl_exec($ch);
curl_close ($ch);实例,给分吧
$ch = curl_init();//初始化
curl_setopt($ch, CURLOPT_URL,"$URL");//模拟抓取的url
curl_setopt($ch, CURLOPT_POST, 1);//设定方式post
curl_setopt($ch, CURLOPT_POSTFIELDS, "u=demo&sc=SZX&ec=KHN&sd=2011-10-19&ed=2011-10-29&showround=&f=&t=");//post相关参数
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
$output = curl_exec($ch);//执行,结果储存到变量中
curl_close ($ch);//关闭
这句是怎么回事呀?
如果注释,,就直接输出来了,如果不注释掉,就报错了.500错误function post($url,$data)
{//模拟请求post数据
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"$url");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );//如果注释就不报错,但是立马输出了.
$output = curl_exec($ch);
curl_close ($ch);
//echo($output)//如果输出就报错
//return $output;
}