OK… really interesting.
I was just about to message you about that!..
In the docs, it says to base64 encode the string and send it as an Auth header…
e.g.
$username = "myLoginUsernameToMyMauticInstance";
$password = "myPasswordToMyMauticInstance";
$str = $username . ":" . $password; echo "<p>str: " . $str . "</p>";
$apikey = base64_encode($str);
Then I did something like this:
$id=2;
$url = $endpoint . "contacts/" . $id; echo "<p>URL: " . $url . "</p>";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Authorization: Basic ' . $apikey)); echo "<p>apikey: " . $apikey . "</p>";
curl_setopt($curl,CURLOPT_FOLLOWLOCATION,true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // Set the result output to be a string.
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$data = curl_exec($curl);
if ($data === false)
{
$info = curl_getinfo($curl);
curl_close($curl);
die('error occured during curl exec. Additional info: ' . var_export($info));
}
else
{
curl_close($curl);
}
$decodedContact = json_decode($data);
echo "<h2>decodedContact</h2>";
echo "<pre>";
print_r($decodedContact);
echo "</pre>";
And it worked …
Is the whole UN & PW in the URL still working then???