I wrote the following PHP code and I always obtain Response HTTP Status Code : 400 Response HTTP Body : 400 Bad Request400 Bad Request when I run it . What goes wrong:
// create curl resource
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, ‘https://myRCserver/api/v1/login -d “user=john&password=doe”’);
//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $resp contains the output string
$resp = curl_exec($ch);
if(!$resp) {
die('Error: "' . curl_error($ch) . '" - Code: ' . curl_errno($ch));
} else {
echo "Response HTTP Status Code : " . curl_getinfo($ch, CURLINFO_HTTP_CODE);
echo "\nResponse HTTP Body : " . $resp;
}
echo $resp ;
// close curl resource to free up system resources
curl_close($ch);