['error_msg' => 'Invalid owner_id']]);
exit;
}
if (!in_array($ownerId, $ALLOWED_GROUPS, true)) {
http_response_code(403);
echo json_encode(['error' => ['error_msg' => 'Group not allowed']]);
exit;
}
$url = 'https://api.vk.com/method/wall.get?' . http_build_query([
'owner_id' => $ownerId,
'count' => $count,
'offset' => $offset,
'filter' => $filter,
'extended' => 1,
'v' => '5.131',
'access_token' => $TOKEN,
]);
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 10,
CURLOPT_SSL_VERIFYPEER => true,
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode !== 200 || $response === false) {
http_response_code(502);
echo json_encode(['error' => ['error_msg' => 'Upstream error']]);
exit;
}
echo $response;