Ich versuche, Anfrage zu Ruhe api von curl zu senden, aber ich habe immer 404 Antwort. Wenn ich die gleiche Anfrage von PhpStorm mache, funktioniert meine Anfrage korrekt. Ich setze die gleichen Header im Rest-Client wie in curl. Was ich falsch mache? Im Folgenden meine PHP-Code und Screenshot der Rest-Client-KonfigurationAnfrage zur Ruhe api funktioniert nicht von php curl, aber funktioniert von PhpStorm Rest Client
$postfields = array(
'SUBSCRIPTION' => 'testlist',
"HTTP_REDIRECT" => 'https://testsite.com',
"HTTP_REDIRECT_ERROR" => 'https://testsite.com/error',
"email" => '[email protected]',
"Sprache" => 'DE'
);
$uri = $uri . '?=' . http_build_query($postfields); // value of uri is http://web.mailingsystem.com/subscription/servlet?=SUBSCRIPTION=testlist&HTTP_REDIRECT=https%3A%2F%2Ftestsite.com%2F&HTTP_REDIRECT_ERROR=https%3A%2F%2Ftestsite.com%2Ferror&email=test%2B100A%40gmail.com&Sprache=DE
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $uri);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_ENCODING, "");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;from testshop;os:".PHP_OS.";)");
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
$headers = [
'Content-Length:'
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$content = curl_exec($ch);
$error = curl_error($ch);
$response = curl_getinfo($ch);
curl_close($ch);
thx für Ihre Hilfe erhalten. Ich musste beide Dinge nach deiner Beschreibung ändern und jetzt funktioniert es richtig. – Rudolf