引用:https://www.cnblogs.com/kenkofox/archive/2011/09/18/2180649.html
1、登录后台管理。(在论坛中,用创建论坛的admin账号登陆,然后点“管理中心”)
2、添加新应用,填写资料。其实就是“名称”和“密钥”重要一些而已。例如我这里添加的“香芋网”
3、复制生成的配置代码,贴到constants.php中(CodeIgniter),或者使用前引入一个配置,在该配置中贴这些配置代码。
然后,就是使用了:参考developguide.zip
在代码中,include discuz目录的uc_client/client.php,例如include_once APPPATH . ‘../bbs/uc_client/client.php‘;
然后就可以按照教程来做了。
例如
include_once APPPATH . ‘../bbs/uc_client/client.php‘;
$uid = uc_user_register("kenko1", "123", "kenkofox1@qq.com");
if ($uid <= 0) {
if ($uid == -1) {
echo ‘用户名不合法‘;
} elseif ($uid == -2) {
echo ‘包含要允许注册的词语‘;
} elseif ($uid == -3) {
echo ‘用户名已经存在‘;
} elseif ($uid == -4) {
echo ‘Email 格式有误‘;
} elseif ($uid == -5) {
echo ‘Email 不允许注册‘;
} elseif ($uid == -6) {
echo ‘该 Email 已经被注册‘;
} else {
echo ‘未定义‘;
}
} else {
echo ‘注册成功‘;
}
include_once APPPATH . ‘../bbs/uc_client/client.php‘;
$uid = uc_user_register("kenko1", "123", "kenkofox1@qq.com");
if ($uid <= 0) {
if ($uid == -1) {
echo ‘用户名不合法‘;
} elseif ($uid == -2) {
echo ‘包含要允许注册的词语‘;
} elseif ($uid == -3) {
echo ‘用户名已经存在‘;
} elseif ($uid == -4) {
echo ‘Email 格式有误‘;
} elseif ($uid == -5) {
echo ‘Email 不允许注册‘;
} elseif ($uid == -6) {
echo ‘该 Email 已经被注册‘;
} else {
echo ‘未定义‘;
}
} else {
echo ‘注册成功‘;
}
另外,同步登录的:
list($uid, $username, $password, $email) = uc_user_login("kenko", "1234");
if ($uid > 0) {
echo ‘登录成功‘;
$ucsynlogin = uc_user_synlogin($uid);
echo ‘登录成功‘ . $ucsynlogin . ‘<br><a href="‘ . $_SERVER[‘PHP_SELF‘] . ‘">继续</a>‘;
} elseif ($uid == -1) {
echo ‘用户不存在,或者被删除‘;
} elseif ($uid == -2) {
echo ‘密码错‘;
} else {
echo ‘未定义‘;
}
if ($uid > 0) {
echo ‘登录成功‘;
$ucsynlogin = uc_user_synlogin($uid);
echo ‘登录成功‘ . $ucsynlogin . ‘<br><a href="‘ . $_SERVER[‘PHP_SELF‘] . ‘">继续</a>‘;
} elseif ($uid == -1) {
echo ‘用户不存在,或者被删除‘;
} elseif ($uid == -2) {
echo ‘密码错‘;
} else {
echo ‘未定义‘;
}
关于uc_user_synlogin函数返回为空的问题,很多人都有疑问,其实这个是返回一段js标记,需要让用户在浏览器上显示这段代码。如下图,我就是只安装了discuz,然后自定义添加一个应用~~
由于我设置了两个应用都同步登录,所以会返回:
<script type="text/javascript" src="http://localhost/bbs/api/uc.php?time=1316354119&code=fd175Sh6Weh9joJTFOPqWv7deuDb8Dc5tt9OaQveB27R6GIvQcw5q4QwCvZEeMqdtS24eU8mDH8L3YCd0%2Fdtiwdo0HPc7bgFw%2Fqpp9q5j%2FJz6xhBPzA2J7LWsGtDqC82xgNx3YlnLihpy4T9Sj5r21NGlFA%2FkHfCumZp" reload="1"></script><script type="text/javascript" src="http://localhost/api/uc.php?time=1316354119&code=9e33iGRg0TqvnyB4cHOreGkukQQxqdoyQDC58GglqRk4%2BBGxerOPuvkQ4vxGx%2FpAjdDJkvjcNxHdFu6eR3pb13Rk1cEVgrXpoL1TnDvL9kS%2BhNe5Nyvs6dzocDbsrg6lO3cfO%2BlgNJxmAKLbvlsrm6rIZdPuaiyWj9VQ" reload="1"></script>
如果还有什么问题,建议debug一下,跟踪一下ucenter的代码
discuz 用户整合 账号整合 ucenter php网站整合discuz用户
标签:安装 yii 就是 lvs cow 疑问 定义 yun mamicode
原文地址:https://www.cnblogs.com/yipianchuyun/p/12181701.html