curl php 身份验证不起作用
我知道有很多问题,但没有一个解决了我的问题,
我必须使用用户名和密码进行身份验证,并使用curl as
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "/example.domain/tmp");
curl_setopt($ch, CURLOPT_USERPWD, "user:pwd");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, 1);
$output = curl_exec($ch);
curl_close($ch);
,但每次它都返回 false。
我对使用 cURL 还很陌生,所以我可能会犯一些初学者错误,但我很困惑为什么这根本不起作用。
任何帮助将不胜感激!
i know there are alot of questions out there but none solved my problem
i have to authenticate with uername and password and used curl as
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "/example.domain/tmp");
curl_setopt($ch, CURLOPT_USERPWD, "user:pwd");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, 1);
$output = curl_exec($ch);
curl_close($ch);
but every time it just returns false.
I'm pretty new to using cURL so I could be making some beginner mistakes, but I'm confused as to why this isn't working at all.
Any help would be greatly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您缺少返回传输,该传输设置为 1
在 CURLOPT_USERPWD 之前写入它,即
它可能会起作用。看看它是否有效。
you are missing return transfer which is set to 1
write it before your CURLOPT_USERPWD i.e
then it might work. see if it work.