Per 2 giorni ho problemi con il mio script PHP sul mio server. Non ho cambiato nulla e all'improvviso non ha funzionato più.PHP - Tipo di contenuto non specificato supponendo applicazione/x-www-modulo-urlencoded
Ecco il codice:
$query = http_build_query($data);
$options = array(
'http' => array(
'header' => "Content-Type: application/x-www-form-urlencoded\r\n".
"Content-Length: ".strlen($query)."\r\n",
'method' => "POST",
'content' => $query,
),
);
$opts = array('http'=>array('header' => "User-Agent:MyAgent/1.0\r\n",'method' => 'POST',
'content' => http_build_query($data),));
$contexts = stream_context_create($opts);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $contexts, -1, 40000);
Ricevo questi messaggi di errore:
Avviso: file_get_contents(): Content-type non nominate assumendo/x-www-form applicazione -urlencoded in
Avviso: file_get_contents (https://mobile.dsbcontrol.de): impossibile aprire lo stream: richiesta HTTP non riuscita! Server interno HTTP/1.1 500 Errore in
Ma quando provo localmente lo script funziona perfettamente.
Mi sono anche imbattuto in questo problema. Sembra che sia stato causato dall'aggiornamento dei pacchetti. Ho aggiunto: $ http ['header'] = 'Content-Type: application/json'. "\ R \ n"; che sopprime l'avviso. –