简体   繁体   English

php Curl登录问题

[英]Php Curl Login Trouble

I'm really amateur to php curl. 我对php curl真的很业余。 I would like to know how to login to a site with form like: 我想知道如何使用以下形式登录网站:

<form method="post" action="/log.php">
  <input type="hidden" name="sessionid" value="a49e4ebb5b71d0745573d37331bfc2cb2880" />Username: 
  <input type="text" name="user" />Password: 
  <input type="password" name="pass" />
  <input type="submit" name="submit" value="Log in" />
</form>

Here you can see a fieldname called "sessionid". 在这里,您可以看到一个名为“ sessionid”的字段名。 It just keeps on changing in every reload. 它只是在每次重新加载中不断变化。 So when i try to login with the curl, it says 'Invalid Session'. 因此,当我尝试使用curl登录时,它会显示“无效会话”。 So can anyone please help me? 那有人可以帮我吗?

This behaviour is absolutely normal. 这种行为是绝对正常的。

Your autologin process can be explained this way : 您的自动登录过程可以通过以下方式进行解释:

在此处输入图片说明

Your problem is at the step 4 : you cannot set a cookie for another domain. 您的问题出在第4步:您不能为另一个域设置Cookie。

  • Your website www.autologin.com has the domain autologin.com 您的网站www.autologin.com的域名为autologin.com

  • The target website www.protected-site.com has the domain protected-site.com 目标网站www.protected-site.com具有域protected-site.com

If you try to set a cookie from www.autologin.com to the domain protected-site.com, your browser will ignore it. 如果尝试将Cookie从www.autologin.com设置为域protected-site.com,则浏览器将忽略它。

Your cURL script should perform his own Login with user and password. 您的cURL脚本应使用用户名和密码执行自己的登录。 There are several Methods (Basic, NTLM, ...) supported by cURL. cURL支持几种方法(基本,NTLM等)。 Further, cURL can handle its own cookies using a cookie jar. 此外,cURL可以使用Cookie罐来处理自己的Cookie。

But once i found a blog where it's admin made a facebook status updater script with curl and i missed it. 但是一旦我找到一个博客,它的管理员用curl制作了一个facebook status updater脚本,我就错过了。 Facebook is having session ids right? Facebook拥有会话ID对吗? But how did he managed to do that? 但是他是如何做到的呢?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM