$cSession = curl_init();
curl_setopt($cSession,CURLOPT_URL,"http://hai:hai@7@redmine.org/users/current.json");
curl_setopt($cSession,CURLOPT_RETURNTRANSFER,true);
$userDetail = curl_exec($cSession);
将密码中“@”后面的字符作为URL。
答案 0 :(得分:0)
不要将您的凭据放在URL字符串中。像这样设置它们:
curl_setopt($cSession, CURLOPT_URL,"http://redmine.org/user/current.json");
curl_setopt($cSession, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($cSession, CURLOPT_USERPWD, "$username:$password");
答案 1 :(得分:0)
您应该urlencode()
用户名和密码。这应该可以解决问题。
$user = 'hai';
$pass = 'hai@7';
$creds = urlencode($user) . ':' . urlencode($pass)
// result hai:hai%407
然后,您可以在网址中传递$creds
字符串,或者传递为CURLOPW_USERPWD
。