开发者

php curl basic authentication as per RFC2617

开发者 https://www.devze.com 2023-02-15 06:08 出处:网络
I want to post data to the urlusing basic authentication as per RFC2617 $header = base64_encode(\"testindia01@test.com:india123\");

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/plai开发者_Go百科n', 'Authorization: Basic '.$header));

What else I need to do here, I am passing ':' separated username and password using base64 encoding?

I am getting 401 response, that is unauthorized where as my username and password are valid, I am able to login using them.

Thanks


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

0

精彩评论

暂无评论...
验证码 换一张
取 消