如何通过JavaScript获取VK.com中的用户状态
嘿伙计们, 我尝试通过 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);
});
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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