G
G
Gfd2016-08-18 16:37:54
Java
Gfd, 2016-08-18 16:37:54

vk + java. Profile parser, how to do?

I want to write a program that will notify the user when the selected people become online. I know a little java, but never worked with parsers. How can this be done more easily?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
_
_umr, 2016-08-18
@Umr001

Does their API not allow you to do this? Google, what else can you say and look at their api, maybe there is a status checker

S
sirs, 2016-08-18
@sirs

The users.get method returns user information, including 'online'. You can read about the field online here

A
arti_djeims, 2016-08-18
@arti_djeims

So be it, I'll give you a gift, I'll write the code for you, lol:
First you need to include jquery in the head

<script src="https://code.jquery.com/jquery-2.1.4.js"></script>

Now you can insert the code itself at the end of body:
var placeHolder = $('#test');  //Id элемента куда будем выводить результат
var url='https://api.vk.com/method/users.get?user_ids=ТУТIDчеловека&fields=online&v=5.45';
  var answer;
  $.ajax
  ({
        url: url,                
        type: 'get',
        crossDomain: true,
        dataType: 'jsonp',
        success: function(response)
        {
          answer = response;
          
          answer.response.forEach(function(item)
          {    

            if(item.online === 1)
            {             
            alert('Пользователь Online!');
            } else {
           alert('Пользователь не Online!');
           }
            
          });                 
        },
        error: function(error)
        {
          console.log('Ошибка');
            console.log(error);
        }
  });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question