PHP: Send basic authentication credentials

PHOTO EMBED

Mon Aug 29 2022 19:49:31 GMT+0000 (UTC)

Saved by @marcopinero #php

<?php

$url = "https://reqbin.com/echo";

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$headers = array(
   "Authorization: Basic bG9naW46cGFzc3dvcmQ=", /*base64_encode(user:pass)*/
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
//for debug only!
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

$resp = curl_exec($curl);
curl_close($curl);
var_dump($resp);

?>

content_copyCOPY