2017-09-06 1 views
1

Ich möchte diesen Terminal-Befehl in PHP-Curl-Format konvertieren, können Sie bitte helfen?Wie konvertiert man den curl-Befehl in php formate?

curl -i -k -3 -X PATCH "http://localhost:8080/api/v2/db/_table/todo/1" \ 
    -H "X-DreamFactory-Api-Key: <api key for app in the apps tab>" \ 
    -H "X-DreamFactory-Session-Token: <session token from login response>" \ 
    -H "Content-Type: application/json" \ 
    -d '{ "complete" : true }' 

Antwort

2
$ch = curl_init(); 

curl_setopt($ch, CURLOPT_URL, "http://localhost:8080/api/v2/db/_table/todo/1"); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, "{ \"complete\" : true }"); 
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PATCH"); 


$headers = array(); 
$headers[] = "X-Dreamfactory-Api-Key: <api key for app in the apps tab>"; 
$headers[] = "X-Dreamfactory-Session-Token: <session token from login response>"; 
$headers[] = "Content-Type: application/json"; 
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 

$result = curl_exec($ch); 
if (curl_errno($ch)) { 
    echo 'Error:' . curl_error($ch); 
} 
curl_close ($ch); 
+0

Vielen Dank für Ihre Antwort –

Verwandte Themen