I was having the same issue, the problem was the wrong curl request. Below is the code which worked!
$ch = curl_init('https://appleid.apple.com/auth/token');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($reqDataArray));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
$serverOutput = curl_exec($ch);
curl_close ($ch);