本文介绍了PHP卷曲基本身份验证的替代品CURLOPT_HTTPHEADER&安培; CURLOPT_USERPWD ...?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有任何替代使用CURLOPT_HTTPHEADER&安培; CURLOPT_USERPWD为卷曲PHP提供基本身份验证?
Are there any alternatives to using CURLOPT_HTTPHEADER & CURLOPT_USERPWD for supplying Basic Authentication for cURL PHP?
我有一个超长的密码,所以CURLOPT_USERPWD不会工作,因为它在截断256个字符。
I have a super long password, so CURLOPT_USERPWD wont work as it truncates at 256 characters.
curl_setopt($data, CURLOPT_USERPWD, $username . ":" . $password);
和我想从使用CURLOPT_HTTPHEADER出于安全原因望而却步。
And I would like to stay away from using CURLOPT_HTTPHEADER for security reasons.
curl_setopt($data, CURLOPT_HTTPHEADER, "Authorization: Basic " . base64_encode($username . ":" . $password));
任何替代方案?
推荐答案
什么让你觉得 CURLOPT_HTTPHEADER
是出于安全考虑停用?
What makes you think CURLOPT_HTTPHEADER
is disabled for security reasons?
它接受的阵列而不是字符串。试试这个:
It accepts an array rather than a string. Try this instead:
curl_setopt($data, CURLOPT_HTTPHEADER,
array(
"Authorization: Basic " . base64_encode($username . ":" . $password)
));
这篇关于PHP卷曲基本身份验证的替代品CURLOPT_HTTPHEADER&安培; CURLOPT_USERPWD ...?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!