
如何在 php 的 curl 中添加身份验证
遇到这样的问题:
get /snapshot?ext=[jpg|png]&compress=[0.1-1]&orient=[0|1|2|3] http/1.1 host: [服务端 ip] auth: [验证串]
需要在 curl 中添加授权,但不知道如何使用哪个函数。
解决方法:
立即学习“PHP免费学习笔记(深入)”;
根据 stackoverflow 上的讨论(参考:http://stackoverflow.com/questions/20064271/how-to-use-basic-authorization-in-php-curl),可以使用 curl_setopt 函数:
curl_setopt($ch, CURLOPT_USERPWD, "<span style="color: #800080">$username</span>:<span style="color: #800080">$password</span>");
以上就是PHP Curl 如何添加身份验证?的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号