Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
VK.com stored procedure that gets user info and location info if present
response: {
user: {
uid: 1,
first_name: 'Павел',
last_name: 'Дуров',
nickname: '',
screen_name: 'durov',
sex: 2,
bdate: '10.10.1984',
city: '2',
country: '1',
photo_medium: 'http://cs7003.vk.me/v7003793/2184/qgHVkPyWj6A.jpg'
},
country: {
cid: 1,
name: 'Россия'
},
city: {
cid: '2',
name: 'Санкт-Петербург'
}
}
var fields = ["uid", "first_name", "last_name", "nickname", "screen_name", "sex", "bdate", "city", "country", "photo_medium"],
uids = [Args.ids];
var user, country, city;
user = API.users.get({uids: uids, fields: fields})[0];
if (""+user.country != "undefined"){
var country_ids = [parseInt(user.country)];
country = API.places.getCountryById({cids: country_ids})[0];
}
if (""+user.city != "undefined"){
var city_ids = [parseInt(user.city)];
city = API.places.getCityById({cids: city_ids})[0];
}
return {
user: user,
country: country,
city: city
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment