简体   繁体   English

密码保护页面,如何使用PHP访问它?

[英]Password protected page, how to access it with PHP?

Say I have a page which is password protected with cPanel's directory password type of thing (htaccess), how could I access this page using PHP? 假设我有一个用cPanel的目录密码类型的东西(htaccess)密码保护的页面,我怎么能用PHP访问这个页面? So the php script would: 所以php脚本会:

  1. Go to the password protected URL 转到受密码保护的URL
  2. Enter the username 输入用户名
  3. Enter the password 输入密码
  4. Return true if it worked, false if it didnt 如果有效则返回true,如果没有则返回false

Any help would be greatly appreciated. 任何帮助将不胜感激。

Check out cURL . 查看cURL

You can set the connection options for CURLOPT_HTTPAUTH and pass the credentials. 您可以为CURLOPT_HTTPAUTH设置连接选项并传递凭据。 There's actually a user comment containing code that should help you get started with Basic Auth. 实际上有一个包含代码用户评论可以帮助您开始使用Basic Auth。

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

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