Answer the question
In order to leave comments, you need to log in
How to use CURL for secure connections? SSL?
I want to connect to the site via CURL, what should I do to make curl work with https? Everything works, but only on http.
Example of my code:
<?PHP
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => ' https://mysite ',
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_HEADER => false,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_REFERER => ' https:// mysite ',
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_USERPWD => "mylogin:mypass",
CURLOPT_USERAGENT => 'Codular Sample cURL Request',
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => array('Content-Type: application/json'),
CURLOPT_USERAGENT => "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)",
CURLOPT_FAILONERROR => false,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => [
'row'=>'data'
]
]);
$res = curl_exec($curl);
echo $res;
curl_close($curl);
?>
Answer the question
In order to leave comments, you need to log in
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
just
test here
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question