开发者

php curl basic authentication as per RFC2617

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜