Skip to content

Instantly share code, notes, and snippets.

@AGenchev
Forked from localhots/example_response.js
Created August 20, 2018 13:39
Show Gist options
  • Save AGenchev/3b60118d750adcd4f022db7d80178672 to your computer and use it in GitHub Desktop.
Save AGenchev/3b60118d750adcd4f022db7d80178672 to your computer and use it in GitHub Desktop.
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