欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 财经 > 金融 > 阿里云一键登录号码认证服务

阿里云一键登录号码认证服务

2024/10/25 3:31:28 来源:https://blog.csdn.net/tiantiantbtb/article/details/139512712  浏览:    关键词:阿里云一键登录号码认证服务

阿里云文档:号码认证SDK_号码认证服务(PNVS)-阿里云帮助中心

对于后端大概流程 前端App会传一个token过来  后端通过下面方法解析  如果解析可以获得号码,说明号码认证成功,如果无法正确解析则认证失败

/*** actoken来换取电话号码* @param token app端用户授权actoken* @return*/public static String getPhone(String token) {DefaultProfile profile = DefaultProfile.getProfile(regionId, accessKeyID, accessKeySecret);//自己阿里云的配置IAcsClient client =new DefaultAcsClient(profile);GetMobileRequest request = new GetMobileRequest();request.setAccessToken(token);//app端传过来的,需要用户授权拿到request.setSysRegionId(regionId);String phone = null;try {GetMobileResponse response = client.getAcsResponse(request);if("OK".equals(response.getCode())) {System.out.println(response.toString());phone = response.getGetMobileResultDTO().getMobile();};System.out.println(new Gson().toJson(response));} catch (ServerException e) {e.printStackTrace();} catch (ClientException e) {System.out.println("ErrCode:" + e.getErrCode());System.out.println("ErrMsg:" + e.getErrMsg());System.out.println("RequestId:" + e.getRequestId());}return phone;}

依赖

<dependency><groupId>com.aliyun</groupId><artifactId>aliyun-java-sdk-core</artifactId><version>4.4.4</version>
</dependency>
<dependency><groupId>com.aliyun</groupId><artifactId>aliyun-java-sdk-dypnsapi</artifactId><version>1.0.4</version>
</dependency>

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com