Ich habe Curl-Befehl durch Terminal arbeiten und wenn ich diesen Befehl in PHP konvertiert, gibt es mir einen Fehler. HierConverting Curl Befehl in PHP funktioniert nicht
ist Curl-Befehl vom Terminal:
[[email protected] ~]# curl -XPOST -v http://localhost:5636/api/1/event/AVyWHzgsJ-3JxxYdx60x/archive
* About to connect() to localhost port 5636 (#0)
* Trying ::1...
* Connected to localhost (::1) port 5636 (#0)
> POST /api/1/event/AVyWHzgsJ-3JxxYdx60x/archive HTTP/1.1
> User-Agent: curl/7.29.0
> Host: localhost:5636
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: application/json
< X-Evebox-Git-Revision: 8ef8639
< X-Evebox-Session-Id: IUi21/bP7TkbJ11jpYcihe1w/S41vyAbP1L1qBIJKJiL8E3440J3imOSGxKYO9j5ffqAPyv2Q3tCXqUQxhIqnw
< Date: Wed, 05 Jul 2017 06:34:31 GMT
< Content-Length: 14
<
* Connection #0 to host localhost left intact
{"status":200}[[email protected] ~]#
Hier ist der Curl-Befehl in PHP:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://localhost:5636/api/1/event/AVyWHzgsJ-3JxxYdx60x/archive");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
Dies ist Antwort: 400 Bad Request
Hier ist die ausführliche Ausgabe:
Verbose information:
* About to connect() to localhost port 5636 (#6) * Trying ::1... * Connected to localhost (::1) port 5636 (#6) > POST /api/1/event/AVyWHzgsJ-3JxxYdx60x/archive HTTP/1.1 Host: localhost:5636 Accept: */* Content-Length: -1 Content-Type: application/x-www-form-urlencoded Expect: 100-continue < HTTP/1.1 400 Bad Request < Content-Type: text/plain; charset=utf-8 < Connection: close < * Closing connection 6
400 Bad Request
versuchen, die Option CURLOPT_VERBOSE zum Debuggen hinzuzufügen – murison
@murison Verbose-Ausgabe zu der Frage hinzugefügt. –