php curl基本认证,符合RFC2617 [英] php curl basic authentication as per RFC2617
本文介绍了php curl基本认证,符合RFC2617的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想根据RFC2617使用基本身份验证将数据发布到url
I want to post data to the url using basic authentication as per RFC2617
$header = base64_encode("testindia01@test.com:india123");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: text/plain', 'Authorization: Basic '.$header));
在这里我还需要做些什么,我正在使用base64编码传递':'分隔的用户名和密码?
What else I need to do here, I am passing ':' separated username and password using base64 encoding?
我收到 401回复,这是未经授权的,因为我的用户名和密码有效,因此我可以使用它们登录.
I am getting 401 response, that is unauthorized where as my username and password are valid, I am able to login using them.
谢谢
推荐答案
使用CURL_USERPWD
和CURLOPT_HTTPAUTH=>CURLAUTH_BASIC
设置代替手动注入Authentication标头.
Instead of manually injecting the Authentication header, use CURL_USERPWD
and the CURLOPT_HTTPAUTH=>CURLAUTH_BASIC
setting.
http://php.net/manual/en/function. curl-setopt.php#98164
这篇关于php curl基本认证,符合RFC2617的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文