快要下班,分开写
我是这样弄的,先在网站根目录建立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';