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
精彩评论