Click here to Skip to main content
15,886,963 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Team

How do i pass this problem? basically i am creating a basic authentication in php using end point. I am using wampp server to test this under the folder www the file is there and cacert.perm both reside. When i called localhost:port and filename.php got this ssl certificate.

What I have tried:

<?php
// Set up the request URL and headers
$url = 'https://www.axxess.co.za/careers/dev-test';
$headers = array(
    'Authorization: Basic ' . base64_encode('applicant:canCode')
);

// Initialize a cURL session
$ch = curl_init();

// Set the cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CAINFO, __DIR__ . '/cacert.pem');

// Set the request data
$data = array(
    'first_name' => 'John',
    'last_name' => 'Doe',
    'mobile_number' => '1234567890',
    'email_address' => 'johndoe@example.com',
);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));

// Execute the request and store the response
$response = curl_exec($ch);

// Check for errors
if(curl_errno($ch)) {
    echo 'Error: ' . curl_error($ch);
}

// Close the cURL session
curl_close($ch);

// Output the response
echo $response;
?>
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900