Sorry to bother you guys but I am a beginner in PHP and want to send a request to a API and want to receive JSON with API key.
What am i doing wrong?
<?php
$url = 'https://10.1.0.5:9443/oauth/token';
$clientsecret = 'password';
$clientid = 'admin';
$myvars = 'client_id=' . $clientid . '&client_secret=' . $clientsecret . '&grant_type=' . 'client_credentials';
echo $myvars;
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $myvars);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec( $ch );
echo $response;
curl_close($ch);
?>
Hope this is enough!