def get_user_info(data) -> object:
oauth_token = data.get('oauth_token')
oauth_token_secret = data.get('oauth_token_secret')
userinfo = {}
userinfo['oauth_token'] = oauth_token
userinfo['oauth_token_secret'] = oauth_token_secret
url = "http://api.openstreetmap.org/api/0.6/user/details"
auth = OAuth1(BaseConfig.OSM_CONSUMER_KEY, BaseConfig.OSM_CONSUMER_SECRET, oauth_token, oauth_token_secret)
resp = requests.get(url, auth=auth)
tree = ElementTree.fromstring(resp.content)
for child in tree:
if child.tag == 'user':
userinfo['display_name'] = child.attrib.get('display_name')
userinfo['id'] = child.attrib.get('id')
for innerChild in child:
if innerChild.tag == 'img':
userinfo['img'] = innerChild.attrib.get('href')
return userinfo
评论列表
文章目录