please format your question with three backticks ``` on their own line before and after the code blocks
Nov 11, 2022
7
Level 18
How to convert this code Laravel Http Post
$url = "https://accounts.com/auth/oauth/v2/token";
$keyFile = dirname(__FILE__) . '/certificates/cert.key';
$certFile = dirname(__FILE__) . "/certificates/cert.pem";
$clientCert = $certFile;//file_get_contents($certFile);
$clientKey = $keyFile;//file_get_contents($keyFile);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_SSLKEY, $clientCert);
curl_setopt($ch, CURLOPT_SSLCERT, $clientKey);
$headers = array();
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSLCERT, $certFile);
curl_setopt($ch, CURLOPT_SSLKEY, $clientKey);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
$access_token = json_decode($result, true);
return $access_token["access_token"] ??"";
How to write this curl code with laravel Http:Post method
Please or to participate in this conversation.