update save response req

This commit is contained in:
2020-09-24 10:30:52 +07:00
parent aade992cf9
commit db801e7d96
6 changed files with 71 additions and 22 deletions

View File

@@ -30,29 +30,18 @@ class SyncController extends Controller {
if ($this->is_connected()) {
$sync = \app\models\SyncUrl::find()->one();
if ($sync) {
$logs = \app\models\FaceLogs::find()->all();
$logs = \app\models\WaitingReq::find()->all();
foreach ($logs as $key => $value) {
$options = [
'http' => [
'header' => "Content-Type: application/json",
'method' => "POST",
'content' => json_encode([
"camera_id" => $value->camera_id,
"confidence" => $value->confidence,
"enable_door" => $value->enable_door,
"encoded_person_image" => $value->encoded_person_image,
"frametime" => $value->frametime,
"id" => $value->face_id,
"image" => $value->image,
"name" => $value->name,
"person_id" => $value->person_id,
"status" => $value->status,
"stt" => $value->stt,
"timezone" => $value->timezone
]),
'content' => $value->content
]
];
file_get_contents($sync->data, false, stream_context_create($options));
$res = json_decode(file_get_contents($sync->data, false, stream_context_create($options)), true);
$modelRes = new \app\models\ResponseReq();
$modelRes->create(json_encode($res));
$value->delete();
}
}