获取用户基本信息
获取用户基本信息
在关注者与公众号产生消息交互后,公众号可获得关注者的OpenID(加密后的微信号,每个用户对每个公众号的OpenID是唯一的。对于不同公众号,同一用户的openid不同)。公众号可通过本接口来根据OpenID获取用户基本信息,包括昵称、头像、性别、所在城市、语言和关注时间。
开发者可通过uid来获取用户基本信息。
URL
https://api.weibo.com/2/eps/user/info
HTTP请求方式
GET
是否需要登录
是
关于登录授权,参见 如何登录授权
接口请求参数
参数详情:
必选 | 类型及范围 | 说明 | |
---|---|---|---|
access_token | true | string | 在粉丝服务平台 - 高级功能 - 开发者模式页面中获取,或者OAuth2.0授权后获得, 详细参考 获取粉丝服务平台开发接口的access token。 |
uid | false | int64 | 需要查询的用户uid。 |
lang | true | string | 场景值ID,临时二维码时为32位非0整型,永久二维码时最大值为100000(目前参数只支持1--100000)。 |
注意事项
- 1、只能获取粉丝信息;
返回结果
{
"subscribe": 1, "openid": "o6_bmjrPTlm6_2sgVt7hMZOPfL2M", "nickname": "Band", "sex": 1, "language": "zh_CN", "city": "广州", "province": "广东", "country": "中国", "headimgurl": "http://wx.qlogo.cn/mmopen/g3MonUZtNHkdmzicIlibx6iaFqAc56vxLSUfpb6n5WKSYVY0ChQKkiaJSgQ1dZuTOgvLLrhJbERQQ4eMsv84eavHiaiceqxibJxCfHe/0", "subscribe_time": 1382694957
}
{
"id": 1404376560, "screen_name": "zaku", "name": "zaku", "province": "11", "city": "5", "location": "北京 朝阳区", "description": "人生五十年,乃如梦如幻;有生斯有死,壮士复何憾。", "url": "http://blog.sina.com.cn/zaku", "profile_image_url": "http://tp1.sinaimg.cn/1404376560/50/0/1", "domain": "zaku", "gender": "m", "followers_count": 1204, "friends_count": 447, "statuses_count": 2908, "favourites_count": 0, "created_at": "Fri Aug 28 00:00:00 +0800 2009", "following": false, "allow_all_act_msg": false, "geo_enabled": true, "verified": false, "status": { "created_at": "Tue May 24 18:04:53 +0800 2011", "id": 11142488790, "text": "我的相机到了。", "source": "<a href="http://weibo.com" rel="nofollow">新浪微博</a>", "favorited": false, "truncated": false, "in_reply_to_status_id": "", "in_reply_to_user_id": "", "in_reply_to_screen_name": "", "geo": null, "mid": "5610221544300749636", "annotations": [], "reposts_count": 5, "comments_count": 8 }, "allow_all_comment": true, "avatar_large": "http://tp1.sinaimg.cn/1404376560/180/0/1", "verified_reason": "", "follow_me": false, "online_status": 0, "bi_followers_count": 215
}
返回值字段 | 字段类型 | 字段说明 |
---|---|---|
uid | int64 | 用户UID |
nicname | string | 用户昵称 |
sex | string | 性别,1:男、2:女、0:未知 |
city | int | 用户所在城市ID
country? |
province | int | 用户所在省级ID |
location | string | 用户所在地 |
language | string | 用户当前的语言版本,zh-cn:简体中文,zh-tw:繁体中文,en:英语 |
headimgurl | string | 用户头像地址(中图),50×50像素 |
name | string | 友好显示名称 |
subscribe | boolean | 是否订阅 |
follow_me | boolean | 该用户是否关注当前登录用户,true:是,false:否 |
subscribe_time | string | 订阅时间 |
// 成功返回 { "ticket": "XXX", "expire_seconds": 1800 } // 失败返回 { "request": "/2/eps/qrcode/create.json", "error_code": 284XX, "error": "error message." }