Kie*_*ley 2 php curl basic-authentication laravel
我正在使用https://github.com/ixudra/curl作为 Laravel 的 Curl 库,有谁知道如何通过 Curl 库运行以下命令;
curl_setopt($process, CURLOPT_USERPWD, $username . ":" . $password);
Run Code Online (Sandbox Code Playgroud)
我需要使用 HTTP 基本身份验证来卷曲一个 url,但似乎无法使用这个库来完成。
小智 7
你的帖子很老了,但我一直在寻找完全相同的东西。您必须使用 withOption 方法:
$response = Curl::to('https://your-url.com')
->withOption('USERPWD', 'user:password')
->post();
Run Code Online (Sandbox Code Playgroud)
如果您想使用任何其他 curl 选项,您必须删除前缀“CURLOPT_”。