<?php
//Твой токен
define('token_user', '...');
// Часовой пояс
date_default_timezone_set('Europe/Volgograd');
// Дата дембеля
$_dembel = '2027-11-25';
$today = date('Y-m-j');
$datetime1 = date_create($today);
$datetime2 = date_create($_dembel);
$interval = date_diff($datetime2, $datetime1);
$_status = $interval->format('%R%a дней до дома =)');
function metog_get ($_metod= null, $_paramm = null) {
$url = trim($_metod.http_build_query($_paramm));
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
$data = curl_exec($curl);
curl_close($curl);
if ($data != null) {
return $data;
} else {
return 'Error = ' .$data;
}
}
$_param = array('text' =>$_status
);
//"response": 1
$_response = metog_get('https://api.vk.com/method/users.get?user_ids=147839882&fields=bdate&access_token=...&v=5.120',$_param);
echo $_response . PHP_EOL;
exit();
?>
{"response":[{"id":147839882,"first_name":"Сергей","last_name":"Арефьев","is_closed":false,"can_access_closed":true,"bdate":"1.1.2001"}]}
$_param = array('text' =>$_status
);
$_response = metog_get('https://api.vk.com/method/users.get?user_ids=147839882&fields=bdate&access_token=...&v=5.120',$_param);
//"response": 1
$_id_status = json_decode($_response)-> response;
if (is_int($_id_status) == 1 ) {
echo 'OK = ' .$_status ;
} else{
echo ('Er = '.$_id_status);
}