Answer the question
In order to leave comments, you need to log in
API data filter How to do?
learned how to get data (list of group members) using the groups.getMembers method
But I can’t figure out how to filter them by gender, city and age
$limit = 1000;
$users = array();
do {
$offset = $page * $limit;
//Получаем список пользователей
$members = json_decode(file_get_contents("https://api.vk.com/method/groups.getMembers?group_id=37372389&v=5.16&offset=$offset&count=$limit&fields=sex,bdate&access_token=$token"),true);
foreach ($members['response']['users'] as $user_array) {
// Если пользователь указал дату рождения и пользователь - мужчина...
if ((isset($user_array['bdate'])) && ($user_array['sex'] == 2)) {
// ... и если в дате рождения три компонента (ДД.ММ.ГГГГ)...
if (count(explode(".", $user_array['bdate'])) == 3) {
// то вычисляем возраст (формулу нашел в интернете)
$age = floor((time()-strtotime($user_array['bdate']))/(60*60*24*365.25));
// Если возраст нам подходит, выводим id пользователя с переводом строки
if ($age > 25) {
echo $user_array['uid'] . "<br/>";
}
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question