Problems with username or pass with colon when setting CURLOPT_USERPWD

后端 未结 3 899
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-19 06:40

We are trying to use curl in PHP5 to login to a website using basic authentication.

Partial code is like this:



        
3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-19 06:59

    so it turns out that it wasn't a problem with the colon.... it was a problem with the authentication scheme.

    at first we were using:

    curl_setopt($curl_conn, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); 
    

    and changing to:

    curl_setopt($curl_conn, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
    

    fixed the problem.

    Our test against another server had its flaws - the server that worked was running IIS on windows, the production server we were having problems with was running apache on linux.

    So i repeat: there are apparently no issues with using usernames or passwords that contain colons with curl. this explains why there would be no documentation of this problem.

    sorry for jumping to conclusions, and thanks for the help.

提交回复
热议问题