ThinkPHP整合UCenter1.6(一)

本文介绍如何在ThinkPHP中整合UCenter1.6,首先在网站根目录创建api文件夹,并添加uc.php文件,运行后会自动生成UC目录。接着将指定内容复制到uc/Lib/Action/IndexAction.class.php文件中,完成初步整合。
摘要由CSDN通过智能技术生成

快要下班,分开写

我是这样弄的,先在网站根目录建立api文件夹

在API文件夹下面添加uc.php

内容如下:

<?php
/*
 * Created on 2011-11-17 by zhjx922
 *
 * http://blog.csdn.net/zhjx922
 */
//加载配置文件
require("../webconfig.php");

// 定义ThinkPHP框架路径
define('THINK_PATH', '../ThinkPHP/');
define('APP_NAME', 'uc');
define('APP_PATH', './uc/');
require(THINK_PATH."/ThinkPHP.php");
App::run();

 

运行一下,在api目录下自动建立UC目录,用过THINKPHP的都知道...

复制以下内容到uc/Lib/Action/IndexAction.class.php

 

<?php
/*
 * UCenter API(ThinkPHP)
 * @by zhjx922
 * http://blog.csdn.net/zhjx922
*/
//error_reporting(0);

define('UC_CLIENT_VERSION', '1.6.0');
define('UC_CLIENT_RELEASE', '20110501');

define('API_DELETEUSER', 1);
define('API_RENAMEUSER', 1);
define('API_GETTAG', 1);
define('API_SYNLOGIN', 1);
define('API_SYNLOGOUT', 1);
define('API_UPDATEPW', 1);
define('API_UPDATEBADWORDS', 1);
define('API_UPDATEHOSTS', 1);
define('API_UPDATEAPPS', 1);
define('API_UPDATECLIENT', 1);
define('API_UPDATECREDIT', 1);
define('API_GETCREDIT', 1);
define('API_GETCREDITSETTINGS', 1);
define('API_UPDATECREDITSETTINGS', 1);
define('API_ADDFEED', 1);
define('API_RETURN_SUCCEED', '1');
define('API_RETURN_FAILED', '-1');
define('API_RETURN_FORBIDDEN', '1');

@define('IN_DISCUZ', true);
@define('IN_API', true);
@define('CURSCRIPT', 'api');

class IndexAction extends Action
{
    //API入口
    public function index()
    {
        define('DENG_ROOT',DENG_PATH);
		require_once DENG_ROOT.'/api/function_core.php';
		//require_once DENG_ROOT.'/api/function_op.php';
		$get = $post = array();
		$code = @{1}GET['code'];parse_str(authcode($code, 'DECODE', UC_KEY), $get);if(time() - $get['time'] > 3600) {exit('Authracation has expiried');}if(empty($get)) {exit('Invalid Request');}include_once DENG_ROOT.'./SSO/Client/lib/xml.class.php';$post = xml_unserialize(file_get_contents('php://input'));if(in_array($get['action'], array('test', 'deleteuser', 'renameuser', 'gettag', 'synlogin', 'synlogout', 'updatepw', 'updatebadwords', 'updatehosts', 'updateapps', 'updateclient', 'updatecredit', 'getcredit', 'getcreditsettings', 'updatecreditsettings', 'addfeed'))) {//$uc_note = new IndexAction();echo $this->$get['action']($get, $post);exit();} else {exit(API_RETURN_FAILED);} }public function _serialize($arr, $htmlon = 0) {if(!function_exists('xml_serialize')) {include_once DENG_ROOT.'./SSO/Client/lib/xml.class.php';
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值