2

I need to authenticate a cURL request. In the docs, they tell me to use

curl https://url.com -u username:password

So, now I want to do this using curl_setopt(), but I cannot figure out what option the -u is.

For -H the equivilant would be the following to set headers, example:

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

But for -u, I cannot figure out the option. Ive tried looking in PHP Docs and Linux Commands

None of theese have helped me further.

I have tried:

$auth = 'foobar:pass1234';
curl_setopt($ch, CURLOPT_USERNAME, $auth);

But this doesn't seem to work, and in PHP Docs they say that it only takes username, and not password aswell (As it says it should for -u in Linux Commands.

Patrick
  • 781
  • 2
  • 5
  • 23

0 Answers0