开发者

How to get user status in VK.com by JavaScript

Hey Guys, I've tried to get User's status on VK.com by JavaScript, but i didn't got it. So, I need to know is User online or not. I need it to use with Greasemonkey and jquery. I've tried to parse friend's list and I tried to work with JS API on VK.com but I don't have enough knowledges to make it. Could you guys give me some examples, please?

Script bellow:

// ==UserScript==
// @name LoveOnline
// @namespace vk.com/dpron
// @description LoveOnline
// @author dpro
// @include *vk.com/*
// @include *vkontakte.ru/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js
// @require http://vkontakte.ru/js/api/xd_connection.js?2
// ==/UserScript==

var RefreshInterval = 20000;

function IsOnline()
{
    var love = $('.labeled a').attr('href');
    var friends = '/friends.php'
    $.get(friends, function(data)
    {
        var Online = 1 
        if (Online != 0) {
            $('.labeled').append(' '+ 'online' + love);
        } else {
            $('.labeled').append(' '+ 'not online');
        }
    });
}

VK.init(function() {
    VK.api("friends.getOnline", {uids:"1,2,3,4"}, function(data) { 
//      ?What here?
    });
  });
$(document).ready(function()
{
    Is开发者_如何学编程Online();
    setInterval(function() { IsOnline() }, RefreshInterval);
});

http://vkontakte.ru/pages.php?o=-1&p=%D0%9E%D0%BF%D0%B8%D1%81%D0%B0%D0%BD%D0%B8%D0%B5+%D0%BC%D0%B5%D1%82%D0%BE%D0%B4%D0%BE%D0%B2+API Some API here, but I think there we have 2 ways: 1. Use API from JS 2. Parse HTML on friends list

VK.com is a facebook analogue in russia and closest countries.


Vk.com has its own API so if this variant suits you there is a possibility to fetch certain user data. Such as his status, etc.

https://vk.com/dev/fields

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜