一。集成机制
(1)ecshop,discuz,dedecms通过/uc_client/client.php向ucenter发送请求,并接收请求响应
(2)ecshop,discuz,dedecms通过 /api/uc.php 响应ucenter主动发过来的信息【其他系统登录,登出信息】,
以上机制与短信客户端软件与短信网关的响应机制一样
(1)短信客户端与短信网关建立长链接【这点与这uc不同,因为uc只用http所以只能用一次断一次】
(2)短信客户端发送短信,短信网关返回短信发送响应
(3)当遇到短信上行,短信网关主动发出信号通知短信客户端,短信客户端回应已经接收到信号。
(4)短信客户端关闭,切断长连接
二。ecshop的注册登录登出ucenter
1.初始化
define('UC_CONNECT', 'mysql');
define('UC_DBHOST', 'localhost:3306');
define('UC_DBUSER', 'root');
define('UC_DBPW', 'mysqlpwd');
define('UC_DBNAME', 'ecshop');
define('UC_DBCHARSET', 'utf8');
define('UC_DBTABLEPRE', '`ecshop`.uc_');
define('UC_DBCONNECT', '0');
define('UC_KEY', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
define('UC_API', 'http://127.0.0.1/ecshop/ucenter/');
define('UC_CHARSET', 'utf-8');
define('UC_IP', '127.0.0.1');
define('UC_APPID', '2');
define('UC_PPP', '20');
2. 注册 /ecshop/user.php
require_once dirname ( __FILE__ ) .'./uc_client/client.php';
$uid = uc_user_register($username, $password, $email);
3.登录/ecshop/user.php
require_once dirname ( __FILE__ ) .'./uc_client/client.php';
list($uid, $username, $password, $email) = uc_user_login($username, $password);
4. 登出/ecshop/user.php
require_once dirname ( __FILE__ ) .'/uc_client/client.php';
$ucresult = uc_user_synlogout();
三。dedecms的注册登录登出ucenter
1.初始化 ecshop/dedecms/include/config_base.php
define('UC_CONNECT', 'mysql');
define('UC_DBHOST', 'localhost');
define('UC_DBUSER', 'root');
define('UC_DBPW', 'mysqlpwd');
define('UC_DBNAME', 'ecshop');
define('UC_DBCHARSET', 'utf8');
define('UC_DBTABLEPRE', '`ecshop`.uc_');
define('UC_DBCONNECT', '0');
define('UC_KEY', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
define('UC_API', 'http://127.0.0.1/ecshop/ucenter');
define('UC_CHARSET', 'utf-8');
define('UC_IP', '127.0.0.1');
define('UC_APPID', '5');
define('UC_PPP', '20');
2.注册ucenter/////////////
/* UC_API: uc_user_register */
if(defined('UC_API')) {
include_once DEDEINC.'/../client/client.php';
$uid = uc_user_register($userid, $pwd, $email);
if($uid <= 0) {
if($uid == -1) {
ShowMsg('用户名不合法',-1);
exit();
} elseif($uid == -2) {
ShowMsg('包含要允许注册的词语',-1);
exit();
} elseif($uid == -3) {
ShowMsg('你指定的用户名已存在,请使用别的用户名!',"-1");
exit();
} elseif($uid == -4) {
ShowMsg('邮箱地址格式不正确!',"-1");
exit();
} elseif($uid == -5) {
ShowMsg('Email 不允许注册',-1);
exit();
} elseif($uid == -6) {
ShowMsg('该 Email 已经被注册',-1);
exit;
} else {
ShowMsg('未定义',-1);
}
} else {
// 'UC_API: 注册成功!';
}
}
/* ...................... */
3.登录ucenter///////////////////
/ecshop/dedecms/member/index_do.php
if(defined('UC_API')) {
/* UC_API: uc_user_login */
include_once DEDEINC.'/../client/client.php';
list($uid, $username, $password, $email) = uc_user_login($userid, $pwd);
...
}
4.登出ucenter///////////////
/ecshop/dedecms/member/index_do.php
/* UC_API: uc_user_synlogout */
if(defined('UC_API')) {
include_once DEDEINC.'/../client/client.php';
$ucsynlogin = uc_user_synlogout();
}
四。discuz的注册登录登出ucenter
1.初始化
// ============================================================================
define('UC_CONNECT', 'mysql');
define('UC_DBHOST', 'localhost');
define('UC_DBUSER', 'root');
define('UC_DBPW', 'mysqlpwd');
define('UC_DBNAME', 'ecshop');
define('UC_DBCHARSET', 'utf8');
define('UC_DBTABLEPRE', '`ecshop`.uc_');
define('UC_DBCONNECT', '0');
define('UC_KEY', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
define('UC_API', 'http://127.0.0.1/ecshop/ucenter');//ceshi
define('UC_CHARSET', 'utf-8');
define('UC_IP', '127.0.0.1');//ceshi
define('UC_APPID', '3');
define('UC_PPP', '20');
2.注册 /ecshop/discuz/register.php
$uid = uc_user_register($username, $password, $email);
if($uid <= 0) {
if($uid == -1) {
showmessage('profile_username_illegal');
} elseif($uid == -2) {
showmessage('profile_username_protect');
} elseif($uid == -3) {
showmessage('profile_username_duplicate');
} elseif($uid == -4) {
showmessage('profile_email_illegal');
} elseif($uid == -5) {
showmessage('profile_email_domain_illegal');
} elseif($uid == -6) {
showmessage('profile_email_duplicate');
} else {
showmessage('undefined_action', NULL, 'HALTED');
}
}
3.ecshop/discuz/logging.php
//ecshop的注册登录登出ucenter
/ecshop/user.php
1.注册ucenter
require_once dirname ( __FILE__ ) .'./uc_client/client.php';
$uid = uc_user_register($username, $password, $email);
if($uid <= 0) {
if($uid == -1) {
showmessage('profile_username_illegal');
} elseif($uid == -2) {
showmessage('profile_username_protect');
} elseif($uid == -3) {
showmessage('profile_username_duplicate');
} elseif($uid == -4) {
showmessage('profile_email_illegal');
} elseif($uid == -5) {
showmessage('profile_email_domain_illegal');
} elseif($uid == -6) {
showmessage('profile_email_duplicate');
} else {
showmessage('undefined_action', NULL, 'HALTED');
}
}
2.登录ucenter
require_once dirname ( __FILE__ ) .'./uc_client/client.php';
$ucresult = uc_user_login($username, $password, $loginfield == 'uid');
3.登出 ucenter
/ecshop/discuz/logging.php
require_once dirname ( __FILE__ ) .'./uc_client/client.php';
$ucsynlogout = uc_user_synlogout();