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
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。