Discuz使用UCenter实现同步登录、注册、退出
2017-09-19 15:37
716 查看
环境
Win7 x64、IIS 7.5、Discuz! X3.4目的
实现 Discuz 和 Net Core 项目的同步操作实现
如果是 Asp.Net 4.0 的项目可以参考:http://www.cnblogs.com/CoreCaiNiao/archive/2011/08/25/2153434.html里面有Demo 可以直接使用。
如果是 Net 4.0 版本以上的项目直接调用就有问题,当前小编也是手动的将所有文件反编译加入到了项目中,虽然有许多方法不能调用(直接使用)或是没有这个方法,但最终功能还是实现了,如果是Net Core的项目,需要整合 其他 Discuze 进行同步操作可以联系小编。
此外,以上方法虽然小编添加了注册方法(之前是没有的),实际上 UCenter 是没有提供的,所以需要做以下改动(也是参考别人的文章写的,但他的文章里方法都是图片,必须手动敲,不知道是有问题还是什么原因,最后是小编自己一步步调试进行修改得到如下正确的修改):
第一步
/uc_server/control/user.php文件中,onsynlogin方法// 新增同步注册功能 function onsynregister(){ $this->init_input(); $username = $this->input('username'); $password = $this->input('password'); $email = $this->input('email'); if($this->app['synlogin']) { $synstr = ''; foreach($this->cache['apps'] as $appid => $app) { if($app['synlogin']) { if($app['appid'] != $this->app['appid']) { $synstr .= '<script type="text/javascript" src="'.$app['url'].'/api/'.$app['apifilename'].'?time='.$this->time.'&code='.urlencode($this->authcode('action=synregister&username='.$username.'&password='.$password.'&email='.$email."&time=".$this->time, 'ENCODE', $app['authkey'])).'" reload="1"></script>'; } if(is_array($app['extra']['extraurl'])) foreach($app['extra']['extraurl'] as $extraurl) { $synstr .= '<script type="text/javascript" src="'.$extraurl.'/api/'.$app['apifilename'].'?time='.$this->time.'&code='.urlencode($this->authcode('action=synregister&username='.$username.'&password='.$password.'&email='.$email."&time=".$this->time, 'ENCODE', $app['authkey'])).'" reload="1"></script>'; } } } return $synstr; } return ''; }
第二步
/uc_client/client.php文件第365行function uc_user_synregister($username,$password,$email){ if(@include UC_ROOT.'./data/cache/apps.php') { if(count($_CACHE['apps']) > 1) { $return = uc_api_post('user', 'synregister', array('username'=>$username,'password'=>$password,'email'=>$email)); } else { $return = ''; } } return $return; }
第三步
在/source/class/class_member.php,第923行注意:在有注释的地方是需要修改的
$param = array('bbname' => $this->setting['bbname'], 'username' => $_G['username'], 'usergroup' => $_G['group']['grouptitle'], 'uid' => $_G['uid']); if(strpos($url_forward, $this->setting['regname']) !== false || strpos($url_forward, 'buyinvitecode') !== false) { $url_forward = 'forum.php'; } // 同步注册 $ucsynregister = $this->setting['allowsynlogin']?uc_user_synregister($_GET['username'],$_GET['password'],$_GET['email']):''; $href = str_replace("'", "\'", $url_forward); $extra = array( 'showid' => 'succeedmessage', 'extrajs' => '<script type="text/javascript">'. 'setTimeout("window.location.href =\''.$href.'\';", '.$refreshtime.');'. '$(\'succeedmessage_href\').href = \''.$href.'\';'. '$(\'main_message\').style.display = \'none\';'. '$(\'main_succeed\').style.display = \'\';'. '$(\'succeedlocation\').innerHTML = \''.lang('message', $locationmessage).'\';'. '</script>'.$ucsynregister,// 同步注册 'striptags' => false, ); showmessage($message, $url_forward, $param, $extra);
总结
不同版本不同语言的项目进行用户操作整合,的确是很麻烦,但终归还是可以解决的,一步步慢慢调试就行的。想要 Net Core操作UCenter实现 Discuze项目登录、注册、退出的源码可以留言lemonwrold@aliyun.com。相关文章推荐
- Yii框架应用程序整合Ucenter实现同步注册、登录和退出等
- Yii框架应用程序整合Ucenter实现同步注册、登录和退出等
- 使用ucenter在第三方应用中实现同步注册与登录
- Yii框架应用程序整合Ucenter实现同步注册、登录和退出等
- 使用ucenter在第三方应用中实现同步注册与登录
- ecshop整合UCenter,discuz,实现会员同步登录 不需要二次登陆
- discuz通过调用函数实现同步登录与退出
- ucenter整合uc.php接口,discuz上初次注册会员后,即可实现自动登录的方法
- discuz使用之三——同步注册和同步登录
- Thinkphp整合ucenter同步登录注册退出
- Asp.Net站点整合Discuz论坛实现同步注册和单点登录
- phpcms和discuz整合论坛实现同步注册登陆退出论坛,所以问题都已经测试了,全部OK!
- ucenter整合uc.php接口,discuz上初次注册会员后,即可实现自动登录的方法
- 【ASP.NET】UCenter实现多站点同步登录退出
- 整合Ucenter同步注册,登录,退出
- ucenter及discuz整合,双向同步注册及登录注意事项2016年9月13
- ucenter及discuz整合,双向同步注册及登录注意事项2016年9月13
- Thinkphp整合ucenter同步登录注册退出
- discuz论坛整合ucenter免激活,同步登录,同步退出解决方案(附源码)
- Asp.Net站点整合Discuz论坛实现同步注册和单点登录