/**
*获取微信的手机号
*/
//加密解密的工具类
public static final StringAES="AES";
public static final String AES_CBC_PADDING="AES/CBC/PKCS7Padding";
@ApiOperation(value="微信家长端手机号获取",notes="微信家长端手机号获取")
@ApiImplicitParams({
@ApiImplicitParam(name="encryptedData",required=true,value="目标密文")
,@ApiImplicitParam(name="sessionKey",required=true,value="会话ID")
,@ApiImplicitParam(name="iv",required=true,value="加密算法的初始向量")
})
@GetMapping("/get_phone.do")
public ResultBody getPhone(
@RequestParam(value="encryptedData",required=true)String encryptedData
,@RequestParam(value="sessionKey",required=true)String sessionKey
,@RequestParam(value="iv",required=true)String iv
){
try{
String result=WxUtils.wxDecrypt(encryptedData,sessionKey,iv);
JSONObject json=JSONObject.parseObject(result);
String PHONE_NUMBER="phoneNumber";
if(json.containsKey(PHONE_NUMBER)){
Stringphone=json.getString("phoneNumber");
if(StringUtils.isNotBlank(phone)){
//写自己的有逻辑
}else{
}
}else{
returnResultBody.failed().data("不存在phoneNumber");
}
}catch(Exceptione){
e.printStackTrace();
}
return ResultBody.failed().data("获取失败");
}