<?php require __DIR__ . '/autoload.php'; use App\Classes\Db; use App\Classes\Upwork; $configDb = json_decode(file_get_contents(__DIR__ . '/config.json')); $db = new Db($configDb); $result['data'] = Upwork::findAll($db); foreach ($result['data'] as $value) { $created_at['display'] = date('d-m-Y H:i:s', $value->created_at); // $created_at['timestamp'] = $value->created_at; $value->created_at = $created_at; } echo json_encode($result, JSON_UNESCAPED_UNICODE);
$res = Upwork::findOne($db, $job->id); if (!isset($res)) { $upwork = new Upwork(); $upwork->sample_id = ++$i; $upwork->sample_date = date('Y-m-d H:i:s'); $upwork->job_id = $job->id; $upwork->url = $job->url; $upwork->title = $job->title; $upwork->description = $job->snippet; $upwork->type = $job->job_type; $upwork->budget = $job->budget === null ? 0 : $job->budget; $upwork->engagement = $job->duration; $upwork->engagement_weeks = $job->workload; $upwork->skills = implode(', ', $job->skills); try { $specific = $profile->getSpecific($job->id); $info = $specific->profile; $upwork->created_at = date('Y-m-d H:i:s', $info->op_ctime / 1000); $upwork->contractor_tier = $info->op_contractor_tier; } catch (OAuthException2 $e) { $logger->addInfo($e->getMessage()); if (preg_match('#Profile.+is disabled#', $e->getMessage()) === 1) { $upwork->created_at = date('Y-m-d H:i:s', strtotime($job->date_created)); $upwork->contractor_tier = 8; } } $upwork->insert($db); } } $result = Upwork::findAll($db); echo json_encode($result, JSON_UNESCAPED_UNICODE);