We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
我用的企业微信是中油定制的企业微信。在获取数据的时候,我的extattr中没有type属性。因此在解析的时候,type是Null,就在
private void buildExtraAttrs(JsonObject o, WxCpUser user) { JsonArray attrJsonElements = o.get(EXTRA_ATTR).getAsJsonObject().get("attrs").getAsJsonArray(); for (JsonElement attrJsonElement : attrJsonElements) { final Integer type = GsonHelper.getInteger(attrJsonElement.getAsJsonObject(), "type"); ---》 这里报错 final WxCpUser.Attr attr = new WxCpUser.Attr().setType(type) .setName(GsonHelper.getString(attrJsonElement.getAsJsonObject(), "name")); user.getExtAttrs().add(attr); switch (type) { case 0: { attr.setTextValue(GsonHelper.getString(attrJsonElement.getAsJsonObject().get("text").getAsJsonObject(), "value")); break; } case 1: { final JsonObject web = attrJsonElement.getAsJsonObject().get("web").getAsJsonObject(); attr.setWebTitle(GsonHelper.getString(web, "title")) .setWebUrl(GsonHelper.getString(web, "url")); break; } default://ignored } } }
<dependency> <groupId>com.github.binarywang</groupId> <artifactId>weixin-java-cp</artifactId> <version>3.8.0</version> </dependency>
经过测试:
@Test void testAttr() { Integer type = null; WxCpUser.Attr attr = new WxCpUser.Attr(); attr.setType(type); }
在传递的type为Null的时候,就会报空指针错误。
而我用的中油即时通的cgi-bin/user/get api的时候,response中extattr":{"attrs":[{"name":"员工编号","value":"xxxxx"}]}就只有这样,没有type或者咱们sdk中所写的那些attr,希望能修改一下。
{ "errcode": 0, "errmsg": "ok", "userid": "zhangsan", "name": "李四", "department": [1, 2], "order": [2, 10], "position": "后台工程师1", "positions": ["后台工程师1","后台工程师2"], "mobile": "15913215421", "hide_mobile": 0, "gender": "1", "email": "[email protected]", "is_leader_in_dept": [1, 0], "avatar": "http://wx.qlogo.cn/mmopen/ajNVdqHZLLA3WJ6DSZUfiakYe37PKnQhBIeOQBO4czqrnZDS79FH5Wm5m4X69TBicnHFlhiafvDwklOpZeXYQQ2icg/0", "telephone": "020-123456", "english_name": "jackzhang", "extattr": {"attrs":[{"name":"爱好","value":"旅游"},{"name":"卡号","value":"1234567234"}]}, "status": 1, "enable": 0, "qr_code": "https://wwlocal.qq.com/wework_admin/userQRCode?vcode=vc2140a8b3c6207c74&lvc=vcf6f1acfdc4b45088" }
https://paste.ubuntu.com/p/ZXVyfxmmtm/
The text was updated successfully, but these errors were encountered:
这个错误看起来还挺简单的,其实楼主可以直接提供PR修复代码
Sorry, something went wrong.
🎨 #1619 企业微信获取用户信息接口优化,处理type为null情况下可能会导致的空指针问题
8256c46
320f367
No branches or pull requests
简要描述
我用的企业微信是中油定制的企业微信。在获取数据的时候,我的extattr中没有type属性。因此在解析的时候,type是Null,就在
模块版本情况
详细描述
经过测试:
在传递的type为Null的时候,就会报空指针错误。
而我用的中油即时通的cgi-bin/user/get api的时候,response中extattr":{"attrs":[{"name":"员工编号","value":"xxxxx"}]}就只有这样,没有type或者咱们sdk中所写的那些attr,希望能修改一下。
即时通API
日志
https://paste.ubuntu.com/p/ZXVyfxmmtm/
The text was updated successfully, but these errors were encountered: