在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:discuz-ucenter-api-for-java开源软件地址:https://gitee.com/rnf/discuz-ucenter-api-for-java开源软件介绍:discuz-ucenter-api-for-java最完美的Discuz UCenter的JAVA API接口,简单易用,完全免费! 相关博文:https://www.renfei.net/posts/1003429 社区论坛:https://bbs.renfei.net/forum-44-1.html 说明此项目移植自https://code.google.com/archive/p/discuz-ucenter-api-for-java / https://github.com/liangping/dzclient4j,感谢原作者梁平 ([email protected])将他的代码开源。 由于原有项目已经非常古老了,看时间应该是2009年的产物,但现在的项目都使用 关于 GPL-2.0 LicenseGPLv2具有很强的传染性,选用这个开源协议并不是我定的,而是原项目作者在开源时就选用了 GPLv2,我也只能跟随原开源协议继续传染下去。 当然,如果您并不注重什么版权协议,那可以无视。 关于程序包名修改也许您注意到源程序的程序包名由 必要条件您的项目环境需要是 安装我使用的是 <dependency> <groupId>net.renfei</groupId> <artifactId>discuz-ucenter-api-for-java</artifactId> <version>1.0.7</version></dependency> 如果你使用的是传统方式,需要下载 使用为了跟 Https(SSL) 站点如果你的站点是 实例化实例化一个客户端 Client client = new Client("http://localhost/uc_server", null, "key", "2",""); 客户端旧的源代码中是通过配置文件注册一个 先创建一个 @Controllerpublic class UCenterController { @ResponseBody @RequestMapping("/api/uc.php") public void uc(HttpServletRequest request, HttpServletResponse response) throws IOException { UCClient ucClient = new UCClient(); Client client = new Client("http://localhost/uc_server", null, "key", "2",""); String result = ucClient.doAnswer(client, request, response); response.getWriter().print(result); }} 如果您想自己处理一些动作的逻辑,只需要继承 注册Client client = new Client("http://localhost/uc_server", null, "key", "2","");String string = client.ucUserRegister("username","password","email"); 登陆Client client = new Client("http://localhost/uc_server", null, "key", "2","");String string = client.ucUserLogin("username","password"); 同步登陆Client client = new Client("http://localhost/uc_server", null, "key", "2","");int UID = 21; //此处是用户的UIDString string = client.ucUserSynlogin(uid); 先登陆再同步登陆Client client = new Client("http://localhost/uc_server", null, "key", "2","");// 登陆String result = client.ucUserLogin(uid);LinkedList<String> rs = XMLHelper.ucUnserialize(result);if(rs.size() > 0){ int uid = Integer.parseInt(rs.get(0)); String username = rs.get(1); String password = rs.get(2); String email = rs.get(3); if(uid > 0) { //同步登陆 String string = client.ucUserSynlogin(uid); //本地登陆代码 //TODO ... .... } else if(uid == -1) { System.out.println("用户不存在,或者被删除"); } else if(uid == -2) { System.out.println("密码错"); } else { System.out.println("未定义"); }}else{ System.out.println("Login failed"); System.out.println(result);} 常见问题在网友使用中出现问题,和我们一起讨论交流的结果将在 https://www.renfei.net/posts/1003429 文章末尾常见问题中更新补充。 代码仓库
更多信息更多信息请阅读源代码,此处不再一一演示。您可以提出issues或者到我的社区论坛一起讨论:https://bbs.renfei.net/forum-44-1.html 求鼓励如果这个项目帮助到了你,是否能给我点个免费的星星 (Star) 给个鼓励呢。高星项目我将持续关注努力更新的。 |
请发表评论