如何通过JavaScript获取VK.com中的用户状态

发布于 2024-10-10 01:21:42 字数 1535 浏览 0 评论 0原文

嘿伙计们, 我尝试通过 JavaScript 获取 VK.com 上的用户状态,但没有成功。 所以,我需要知道用户是否在线。 我需要它与 Greasemonkey 和 jquery 一起使用。 我尝试解析朋友的列表,并尝试使用 VK.com 上的 JS API,但我没有足够的知识来实现​​它。 请大家给我举一些例子好吗?

脚本如下:

// ==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()
{
    IsOnline();
    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 这里有一些 API,但我认为我们有 2 种方法: 1. 使用 JS 中的 API 2. 解析好友列表上的 HTML

VK.com 是俄罗斯和最近国家的 Facebook 类似物。

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()
{
    IsOnline();
    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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青衫负雪 2024-10-17 01:21:42

Vk.com 有自己的 API,因此如果此变体适合您,则可以获取某些用户数据。比如他的状态等等

https://vk.com/dev/fields

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文