现在的位置: 首页 > 综合 > 正文

ucenter 和 uchome的整合心得

2013年01月02日 ⁄ 综合 ⁄ 共 1356字 ⁄ 字号 评论关闭

简介:这是ucenter 和 uchome的整合心得的详细页面,介绍了和php,有关的知识、技巧、经验,和一些php源码等。

class='pingjiaF' frameborder='0' src='http://biancheng.dnbcw.info/pingjia.php?id=343928' scrolling='no'>

1.每一个应用都包含uc_client,拿uchome举例

2.uchome登陆时访问source/do_login.php 的getpassport函数,getpassport通过uc_client 直接连ucenter的数据库,实现当前站点的登陆

3.uchome然后调用$ucsynlogin = uc_user_synlogin($setarr['uid']);实现跨域登陆

4.在uc_user_synlogin函数里再用uc_client/client.php的fsockopen去访问ucenter下的index.php默认超时15秒

5.在ucenter下的index.php根据请求的model和action和appid请求control/user.php 的onsynlogin函数

6.onsynlogin函数通过循环,对系统下的所有应用(在data/cache/setting.php)做JS调用如下
$synstr .= '<script type="text/javascript" src="'.$app['url'].'/api/uc.php?time='.$this->time.'&code='.urlencode($this->authcode('action=synlogin&username='.$this->user['username'].'&uid='.$this->user['uid'].'&password='.$this->user['password']." mce_src="'.$app['url'].'/api/uc.php?time='.$this->time.'&code='.urlencode($this->authcode('action=synlogin&username='.$this->user['username'].'&uid='.$this->user['uid'].'&password='.$this->user['password']."&time=".$this->time, 'ENCODE', $app['authkey'])).'"></script>';

7.返回到uchome.在每个应用下的api目录有个uc.php文件查找$action == 'synlogin'下面是进行cookie设置
obclean();
header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
这两行是必须的

8.这样就在所有ucenter知道的应用下添加了cookie实现了跨域登陆

爱J2EE关注Java迈克尔杰克逊视频站JSON在线工具

http://biancheng.dnbcw.info/php/343928.html pageNo:5

抱歉!评论已关闭.