Php 自动登录到Stackoverflow

Php 自动登录到Stackoverflow,php,login,Php,Login,有时登录到会让我非常恼火,我只想通过调用一个PHP文件来完成。我试着这样做,发送了一个post请求,如下所示: <?php $url = 'https://stackoverflow.com/users/login?ssrc=head&amp;returnurl=http%3a%2f%2fstackoverflow.com%2f'; $data = array('email' => 'mymail@gmail.com', 'password' => 'mypasswor

有时登录到会让我非常恼火,我只想通过调用一个PHP文件来完成。我试着这样做,发送了一个post请求,如下所示:

<?php
$url = 'https://stackoverflow.com/users/login?ssrc=head&amp;returnurl=http%3a%2f%2fstackoverflow.com%2f';
$data = array('email' => 'mymail@gmail.com', 'password' => 'mypasswort');

$options = array(
    'http' => array(
        'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
        'method'  => 'POST',
        'content' => http_build_query($data),
    ),
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);

var_dump($result);
?>


我还尝试了包括更多的值,如
ssrc
fkey
,但我只是在提交后显示SO主页。它甚至停留在localhost(或者脚本运行的任何地方)。如果我输入了错误的密码,它会将其标记为不正确-因此它必须至少以某种方式工作(数据验证).

您必须发送post数据:

isSignup:false
isLogin:true
isPassword:false
isAddLogin:false
hasCaptcha:false
fkey:922b6dc5a5a375283c44e298246d7763
ssrc:head
email:asd
password:
submitbutton:Log in
oauthversion:
oauthserver:
openidusername:
openididentifier:
您应该首先发送GET请求,然后从结果页面解析
fkey
(这是保护)。
fkey
您应该发送带有POST请求以及我向您展示的POST数据

简单的例子:


登录页面是否有csrf保护?我添加了缺少的值,但得到了相同的结果:我也阅读了SO api,但它看起来像是用于处理特定帖子和用户的操作…发送请求之前是否解析表单<代码>fkey
-这是动态值我所做的就是我在问题中写的东西。。。这就是正在执行的整个脚本