$p['user_id']))[0]; $response[] = [ 'id' => $p['id'], 'place' => htmlspecialchars($p['place']), 'date' => $date, 'user_name' => $user['username'], 'user_id' => $p['user_id'], 'photourl' => $p['photourl'], 'photourl_small' => 'https://' . $_SERVER['SERVER_NAME'] . '/api/photo/compress?url=' . $p['photourl'] ]; } } else { $url = 'https://transphoto.org/api.php?action=get-recent-photos&width=802&lastpid=0&hidden=0'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $responsed = curl_exec($ch); if (curl_errno($ch)) { $response = [ 'error' => 1, 'errorcode' => 'СТТС не отвечает. Попробуйте позже' ]; } else { $data = json_decode($responsed, true); foreach ($data as $d) { $response[] = [ 'id' => $d['pid'], 'place' => strip_tags($d['links']), 'date' => $d['pdate'], 'photourl_small' => 'https://transphoto.org'.$d['prw'], ]; } } curl_close($ch); } header('Content-Type: application/json'); echo json_encode($response); } }