【发布时间】:2016-03-28 01:03:07
【问题描述】:
我在网上搜索,一无所获。
在网站上,有一个电子邮件地址的输入框。我想用电子邮件地址填写此字段并发送表格。 我找到了这段代码:
$postdata = http_build_query(
array(
'email' => 'youremailaddress'
)
);
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
$context = stream_context_create($opts);
$result = file_get_contents('http://example.com/submit.php', false, $context);
但在我的情况下,操作文件是当前页面本身,并且 url 被重写。所以当我这样输入网址时:
$result = file_get_contents('http://example.com/login.html', false, $context);
var_dump($result);
我得到了页面,但没有发送表单
【问题讨论】:
-
你是否在目标站点验证了请求类型是POST,并且唯一的字段是email(具体来说,没有CSRF token)?
-
也许试试 Goutte? packagist.org/packages/fabpot/goutte
标签: php