我正在尝试用php进行curl post
我试图提交的页面有这样的代码
<input name="fname" type="hidden" value="show">
<input name="method" type="submit" value="Continue">
我正在尝试模拟这个"sumbit"(继续)按钮,并使用php进行重定向
$post= array("method=>Continue")
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, '/tmp/cookies.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, '/tmp/cookies.txt');
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1);
$h = curl_exec($ch);
echo $h;
$post=数组(?)中应该包含什么。我已经尝试过$post=array(名称=>方法)。不工作。。有什么想法吗?
您可以将CURLOPT_POSTFIELDS
选项设置为数组本身:
$post = array(
"method" => "Continue",
"fname" => "show"
);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $post);