码迷,mamicode.com
首页 > Web开发 > 详细

curl 模拟表单提交

时间:2015-04-08 16:41:20      阅读:125      评论:0      收藏:0      [点我收藏+]

标签:curl   curl post   curl get   curl模拟表单提交   

//GET方式

$url = "/Api/Raiders/doEditRaiders?content=123";

$ch = curl_init ();

curl_setopt ( $ch, CURLOPT_URL, $url );

curl_setopt ( $ch, CURLOPT_HEADER, 0 );

curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );

$return = curl_exec ( $ch );

curl_close ( $ch );


print_r($return);


//POST方式

$url = "/Api/Raiders/doEditRaiders";

// 参数数组

$data[‘content‘] = $_POST[‘content‘];


$ch = curl_init ();

curl_setopt ( $ch, CURLOPT_URL, $url );

curl_setopt ( $ch, CURLOPT_POST, 1 );

curl_setopt ( $ch, CURLOPT_HEADER, 0 );

curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );

curl_setopt ( $ch, CURLOPT_POSTFIELDS, $data );

$return = curl_exec ( $ch );

curl_close ( $ch );


print_r($return);


本文出自 “php工程师的博客” 博客,请务必保留此出处http://340411305.blog.51cto.com/7627178/1630068

curl 模拟表单提交

标签:curl   curl post   curl get   curl模拟表单提交   

原文地址:http://340411305.blog.51cto.com/7627178/1630068

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!