如何将以下 curl 命令转换为 php 甲酸?

How to convert below curl command in to php formate?

我想将此终端命令转换为 php curl 格式,或 http post 你能帮忙吗?

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 }'
$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);

最简单的方法可能是使用 cURL。有关示例,请参阅 http://codular.com/curl-with-php