Curl提示用户名和密码 [英] Curl to prompt a User Name and Password

查看:370
本文介绍了Curl提示用户名和密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网站上有一个密码保护的网络文件夹,我正在使用 Curl 在另一个域中抓取该文件夹,我想要的是:当我尝试打开网址它应该询问我用户名和密码,而不是要求它显示需要授权。

I have a password protect web folder on my site, I am fetching that folder on another domain using Curl, what I want is: when I try to open the URL it should ask me the user name and password, instead of asking it display the "Authorization Required".

示例:

  • http://www.domain.com/admin (password protected using htpasswrd htaccess)
  • http://www.2nddomain.com/admin

如果我尝试访问aurl,它会要求我输入用户名密码。精细。
,但它不要求我在b上使用用户名和密码(在这里使用curl)。

If I try to access the "a" url it ask me for the user name password. Fine. but it doesn't ask me for the user name and password on "b" (using curl here).

任何想法?

简而言之:我想让 Curl 请求用户/密码提示。

In Short: I want to make Curl ask for the User/Password prompt.

谨慎

我不确定,如果可能的话?但如果可能,请让我知道如何,否则我会将其关闭为无效

I am not sure, if it is possible or not? but if it's possible so please let me know how, otherwise I will close this as "Invalid"

推荐答案

这是我需要的,希望它能帮助别人!

This is what I need, hope it helps someone!

为了获得 URL /文件夹通过CURL,我们需要提供用户名/密码到CURL像一个例子@pizza说,但有两个东西。

1-)我们需要一个提示这里。 br>
2-)我们不想HardCoded第二个域上的用户名和密码。

In Order to get the "password protected" URL/Folder via CURL, we need to supply the username/password into the CURL like an example @pizza said, But there are 2 more things.
1-) We need a Prompt Here.
2-) We Don't want to HardCoded the username and password on second domain.

因此,我们将放置PHP_AUTH_USER和页面顶部的密码提示,然后将参数通过CURL传递到目标URL /文件夹。


是的,我知道这很简单,但有时你只是可以' t找出正确的尺寸..

so, we will place PHP_AUTH_USER and password prompt at the top of the page, and then will pass the argument via CURL to the destination URL/Folder.

Yes yes, I know it's simple, but sometime you just can't figure out on a correct dimensions..

这篇关于Curl提示用户名和密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆