-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: 'Санкт-Петербург' | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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