简体   繁体   English

在网站上显示登录内容

[英]Displaying Logged in Content on a Website

I'm not quite sure how to describe this in words without making it overly complex, so here is basically what I want to happen: 我不太确定如何用语言来描述它而不使其变得过于复杂,所以这基本上就是我想要发生的事情:

  1. The user goes to my website, let's say: www.example.com/ 用户访问了我的网站,例如:www.example.com/
  2. The server goes to another website, example2.com, which has a field where their users should enter their username and password 服务器转到另一个网站example2.com,该网站上有一个用户应在其中输入用户名和密码的字段
  3. The server inputs the username and password automatically, and then gets redirected to a "user section" of the site. 服务器自动输入用户名和密码,然后将其重定向到站点的“用户部分”。
  4. The server clicks on one of the links on the sidebar, and gets sent to another page "user section". 服务器单击侧栏上的链接之一,然后发送到另一页面“用户部分”。
  5. Then, the site grabs all of the content on this page, and displays it on example.com 然后,该网站将获取此页面上的所有内容,并将其显示在example.com上

The reason I am attempting to do this is to create an RSS feed out of a website that has a username and password part where the user has to log in. I have not seen a RSS creating website that enables you to do this, which is why I am trying to accomplish it this way. 我尝试执行此操作的原因是从具有用户名和密码部分的网站创建RSS提要,而用户必须在其中登录。我没有看到RSS创建网站可以使您执行此操作,这是为什么我要尝试以这种方式完成它。 However, if anyone knows of a RSS website that will enable you to do this, that would also be great. 但是,如果有人知道RSS网站可以使您做到这一点,那也很好。

Thanks for any help! 谢谢你的帮助!

It sounds like you might be looking for cURL and cookiejar: 听起来您可能正在寻找cURL和cookiejar:

http://curl.haxx.se/libcurl/php/examples/cookiejar.html http://curl.haxx.se/libcurl/php/examples/cookiejar.html

This will allow you to programmatically login to a site, keep a session open, and then access the login protected content. 这将允许您以编程方式登录到站点,保持会话打开,然后访问受登录保护的内容。 Once you get the page contents, then you can use DomDocument ( http://us2.php.net/manual/en/domdocument.loadhtml.php ) to access the content you need and turn it into RSS data. 一旦获得页面内容,就可以使用DomDocument( http://us2.php.net/manual/en/domdocument.loadhtml.php )访问所需的内容并将其转换为RSS数据。

Edit: if the website uses form keys, like many do, this will require extra work to extract the form key from the login page and add it to the login POST 编辑:如果网站像许多人一样使用表单密钥,这将需要额外的工作才能从登录页面提取表单密钥并将其添加到登录POST

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

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