XH通用登录v1.2及以上版本
该版本功能说明:
例如,我现在已登录OA系统,用户名为测试,邮箱为css@qq.com,手机号码为178。如果在Dzz系统中也存在相同的用户名、电子邮件地址和手机号码,那么通过这个特殊链接打开Dzz后就是该用户的帐号。如果Dzz系统中没有这些信息,则会根据特殊链接中的帐户名和邮箱在Dzz系统中注册一个新帐户,并使用默认密码登录。管理员可以修改默认密码。
接口地址:index.php?mod=xhlogin
;
请求方式:跳转方式;
请求地址:
http://127.0.0.1/index.php?mod=xhlogin&dateline=XXX&email=XXX&phone=XXX&username=XXX&
token
=XXX&redirect=X
XX
接口说明:验证成功后跳转到DzzOffice首页或者指定的页面。注意:该接口可以直接通过后端登陆某个账号,注意安全保密,切勿泄露XH通用登录KAY,建议定期更换;
请求参数:
参数 | 类型 | 示例值 | 描述 | 是否必填 |
dateline | int | 1712215131 | 超时时间60秒 | 是 |
username | string | 测试 | 用户名 | 三选一 |
string | css@qq.com | 邮箱 | 三选一 | |
phone | string | 178 | 手机号 | 三选一 |
redirect | string | http://127.0.0.1/index.php?mod=corpus | 登录成功后,跳转的地址。默认跳转到首页 | 否 |
token | string | 6aafb1afaab15c7d44b8a1e0733eb7e7f350a48ab8441353d5d29bd3ba116543 | 签名字符串 | 是 |
组合后的地址类似于:
http://127.0.0.1/index.php?mod=xhlogin&dateline=1712215131&email=css%40qq.com&phone=178&redirect=http%3A%2F%2F127.0.0.1%2Findex.php%3Fmod%3Dcorpus&username=%E6%B5%8B%E8%AF%95&token=6aafb1afaab15c7d44b8a1e0733eb7e7f350a48ab8441353d5d29bd3ba116543
注意:
登录用户可以只填写username、email、phone三者中的任意一个参数值。系统在检测到username、email、phone三个参数中任意一个有效值时,将判断为账号已存在于Dzz中,并允许登录。若三个参数均不存在,系统将判断是否允许注册。在允许注册的情况下,用户需至少填写username和email参数才能进行注册。否则,系统将提示登录失败。在注册时,phone参数为可选填写。
示例(php):
$key='bljt@2023';//XH通用登录KAY
//参数
$params=array(
'dateline' => '1712215131',
'email'=>'css@qq.com',
'username'=>'测试',
'phone' =>'178',
'redirect' =>'http://127.0.0.1/index.php?mod=corpus'
);
//将参数按key升序排列
ksort($params);
/* 排序后参数数组
Array ( [dateline] => 1712215131 [email] => css@qq.com [phone] => 178 [redirect] => http://127.0.0.1/index.php?mod=corpus [username] => 测试 ) 1
*/
//将参数转换为url-encode字符串
$httpstr=http_build_query($params);
/* 编码后的签名字符串
dateline=1712215131&email=css%40qq.com&phone=178&redirect=http%3A%2F%2F127.0.0.1%2Findex.php%3Fmod%3Dcorpus&username=%E6%B5%8B%E8%AF%95
*/
//使用sha256计算签名
$token = hash_hmac('sha256',$httpstr,$key);
/*计算后的签名值
6aafb1afaab15c7d44b8a1e0733eb7e7f350a48ab8441353d5d29bd3ba116543
*/
/*组合后的地址
http://127.0.0.1/index.php?mod=xhlogin&dateline=1712215131&email=css%40qq.com&phone=178&redirect=http%3A%2F%2F127.0.0.1%2Findex.php%3Fmod%3Dcorpus&username=%E6%B5%8B%E8%AF%95&token=6aafb1afaab15c7d44b8a1e0733eb7e7f350a48ab8441353d5d29bd3ba116543
*/
dheader("Location: http://127.0.0.1/index.php?mod=xhlogin&$httpstr&token=$token&redirect=$redirect");
注意:
示例当中的参数即规定键名(数值或字符串)不能去掉,可以没有规定键值。比如说没有用户名、手机号和跳转地址参数值,只有邮箱参数值,就是如下代码:
$key='bljt@2023';//XH通用登录KAY
//参数
$params=array(
'dateline' => '1712215131',
'email'=>'css@qq.com',
'username'=>'',
'phone' =>'',
'redirect' =>''
);
//将参数按key升序排列
ksort($params);
/* 排序后参数数组
Array ( [dateline] => 1712215131 [email] => css@qq.com [phone] => 178 [redirect] => [username] => ) 1
*/
//将参数转换为url-encode字符串
$httpstr=http_build_query($params);
/* 编码后的签名字符串
dateline=1712239748&email=css%40qq.com&phone=178&redirect=&username=
*/
//使用sha256计算签名
$token = hash_hmac('sha256',$httpstr,$key);
/*计算后的签名值
3a5eeaff26bcac7a41da57d560734922791268782a38e4c539014697cee00eeb
*/
/*组合后的地址
http://127.0.0.1/index.php?mod=xhlogin&dateline=1712215131&email=css%40qq.com&phone=178&redirect=&username=&token=3a5eeaff26bcac7a41da57d560734922791268782a38e4c539014697cee00eeb
*/
dheader("Location: http://127.0.0.1/index.php?mod=xhlogin&$httpstr&token=$token&redirect=$redirect");
提示信息说明:
提示信息可在系统日志-用户登录中查看详细信息。
更多建议: