Kieran Headley
Kieran Headley

Reputation: 667

Http Basic Authentication using Laravel Curl Library

I am using https://github.com/ixudra/curl as a Curl library for Laravel does anyone know how to run the below command through the Curl Library;

curl_setopt($process, CURLOPT_USERPWD, $username . ":" . $password);

I need to curl a url using HTTP basic authentication and cant seem to complete using this library.

Upvotes: 2

Views: 3226

Answers (1)

CT-Web
CT-Web

Reputation: 86

Your post is quite old, but I was looking for exactly the same thing. You have to use the method withOption :

 $response = Curl::to('https://your-url.com')
                       ->withOption('USERPWD', 'user:password')
                       ->post();

If you want to use any other curl option, you have to remove the prefix "CURLOPT_".

Upvotes: 7

Related Questions