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);


你可能感兴趣的:(post,get,curl,curl,curl,模拟表单提交)