最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

php curl模擬post提交數(shù)據(jù)示例

 更新時(shí)間:2013年12月31日 15:52:53   作者:  
本文主要介紹了php curl模擬post提交數(shù)據(jù)的方法,大家參考使用吧

復(fù)制代碼 代碼如下:

<?
header("Content-type: text/html; charset=utf8");
/*
 * 提交請(qǐng)求
* @param $header array 需要配置的域名等header設(shè)置 array("Host: devzc.com");
* @param $data string 需要提交的數(shù)據(jù) 'user=xxx&qq=xxx&id=xxx&post=xxx'....
* @param $url string 要提交的url 'http://192.168.1.12/xxx/xxx/api/';
*/
function curl_post($header,$data,$url)
{
 $ch = curl_init();
 $res= curl_setopt ($ch, CURLOPT_URL,$url);
 var_dump($res);
 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
 curl_setopt ($ch, CURLOPT_HEADER, 0);
 curl_setopt($ch, CURLOPT_POST, 1);
 curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
 curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
 $result = curl_exec ($ch);
 curl_close($ch);
 if ($result == NULL) {
  return 0;
 }
 return $result;
}

$url = 'http://127.0.0.1' ;

$header = array("Host:127.0.0.1",
  "Content-Type:application/x-www-form-urlencoded",
  'Referer:http://127.0.0.1/toolindex.xhtml',
  'User-Agent: Mozilla/4.0 (compatible; MSIE .0; Windows NT 6.1; Trident/4.0; SLCC2;)');


$data = 'tools_id=1&env=gamma';
echo "argv:$data<br>";

$ret = curl_post($header, $data,$url);
$utf8 = iconv('GB2312', 'UTF-8//IGNORE', $ret);
echo 'return:<br>'.nl2br($utf8 ).'<br>';
?>

相關(guān)文章

最新評(píng)論

汉寿县| 宁武县| 巨鹿县| 青海省| 墨玉县| 左云县| 白河县| 乌拉特后旗| 武宣县| 朝阳市| 澄迈县| 赤壁市| 中牟县| 遂川县| 九龙城区| 石楼县| 即墨市| 深圳市| 大渡口区| 富平县| 合肥市| 太和县| 平南县| 广元市| 望江县| 南澳县| 万载县| 乐至县| 阿克陶县| 宁武县| 潢川县| 东兰县| 图们市| 尉犁县| 内黄县| 穆棱市| 余干县| 色达县| 三台县| 阳高县| 伊金霍洛旗|