Home >Backend Development >PHP Tutorial >Tencent RTX API development, open a skylight for RTX, rtx_PHP tutorial

Tencent RTX API development, open a skylight for RTX, rtx_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:21:54800browse

Tencent RTX’s API development opens a skylight for RTX, rtx

Many people may not have heard of the RTX software. Here I will briefly explain that this software is developed by Tencent. An internal chat software developed by an enterprise. The server is not hosted by Tencent. Instead, the enterprise needs to install it on its own internal server for internal employees to communicate and use. Its functions are similar to QQ, but a little weaker than QQ.

Strictly speaking, RTX actually provides an API interface, but it is not very good. Recently, the company has a need for this, so I rewrote this API. In addition, the main reason for rewriting is that RTX comes with it. The API will be garbled when encountered in Chinese, and there are many miscellaneous problems. An Internet search found that there are very few discussion topics about RTX API. It is probably because people don’t pay much attention to this software.

Just imagine, when interacting with the website, in addition to using the website to send emails or mobile phone text messages, we can also send instant messages to RTX, so that employees within the company can understand the needs of website visitors in a timely manner. In order to achieve this purpose, so I rewrote the RTX API within our company. The rewritten API can add RTX users, modify user information, delete users, obtain all user lists, obtain certain users based on status, and obtain internal information within the company. Organizational structure, send instant notifications to certain users, send instant messages to certain users, etc. I will directly enter the code below:

<?PHP
require('_class.php');

//驗證使用這個API的用戶身份是否合法?
$K='twboss_rtx';	//d6904e27b5c274b1d6acaadda88ec131
$key=Fun::toGet('key');
if($key!=md5($K)){
	exit('Error:'.__LINE__.', 您無權使用該API!');
}unset($key,$K);

$action=Fun::toGet('action');
switch(strtolower($action)){
case 'add':					//新增RTX用戶
	_Add();
	break;
case 'mdy':					//修改某人的RTX登入密碼
	_Mdy();
	break;
case 'del':					//刪除某人
	_Del();
	break;
case 'setdept':				//修改用戶所屬部門
	_Setdept();
	break;
case 'userlist':			//獲取RTX用戶列表
	_Userlist();
	break;
case 'deptlist':			//獲取組織架構列表
	_Deptlist();
	break;
case 'getstatus':			//獲取用戶在線狀態
	_Getstatus();
	break;
case 'getuserbystatus':		//提取某種類型的用戶列表
	_Getuserbystatus();
	break;
case 'sendtz':				//發通知給某人或某幾個人
	_Sendtz();
	break;
case 'sendim':				//發送消息給某人
	_Sendim();
	break;
default:
	break;
}

/**
	交流:
		QQ群:223494678
	參數:
		key:必填,API密鈅
		action:必填,操作指令
		user:必填,只能由英文和數字組成,長度不能小於3
		pass:必填,只能由英文,數字和底線組成,長度不能小於3
		title是用戶真實姓名,可以用中文
	用法:
		$a=file_get_contents('http://10.20.30.40:8012/_api.php?key=d6904e27b5c274b1d6acaadda88ec131&action=add&user=7di&pass=123123&title='.iconv('UTF-8','big5','馮健'));
		echo '<pre class="brush:php;toolbar:false">',var_dump($a),'
'; /**/ function _Add(){ $user=Fun::toGet('user'); //登入名 $pass=Fun::toGet('pass'); //登入密碼 $title=Fun::toGet('title'); //真實姓名 if($user=='' or $pass==''){exit('Error:'.__LINE__.', 登入名或密碼不能為空!');} $title=($title=='') ? $user : $title; if(!Fun::Preg("^[a-zA-Z0-9]{3,16}$",'chk',$user)){exit('Error:'.__LINE__.', 登入名稱只能有英文和數字組成,並且長度範圍是3~16');} if(!Fun::Preg("^[a-zA-Z0-9._]{3,16}$",'chk',$pass)){exit('Error:'.__LINE__.', 登入密碼只能有英文,數字和底線組成,並且長度範圍是3~16');} try{ $RootObj= new COM('RTXSAPIRootObj.RTXSAPIRootObj'); $RootObj -> ServerIP= '127.0.0.1'; $RootObj -> ServerPort= '8006'; $UserManagerObj=$RootObj -> UserManager; if(($UserManagerObj -> IsUserExist($user))===FALSE){ $UserManagerObj -> AddUser($user,0); //添加用户 $UserManagerObj -> SetUserPwd($user,$pass); $UserManagerObj -> SetUserBasicInfo($user,$title,0,'','','',0); echo '200 ok'; }else{ exit('Error:'.__LINE__.',用戶已存在!'); } }catch(Exception $e){ echo '
',Var_Dump($e->getMessage()),'
'; } die(); } /** 交流: QQ群:223494678 參數: key:必填,API密鈅 action:必填,操作指令 user:必填,只能由英文和數字組成,長度不能小於3 pass:必填,只能由英文,數字和底線組成,長度不能小於3 title:選填,用戶真實姓名,可以用中文 用法: $a=file_get_contents('http://10.20.30.40:8012/_api.php?key=d6904e27b5c274b1d6acaadda88ec131&action=mdy&user=7di&pass=123123&title='.iconv('UTF-8','big5','馮健')); echo '
',var_dump($a),'
'; /**/ function _Mdy(){ $user=Fun::toGet('user'); //登入名 $pass=Fun::toGet('pass'); //登入密碼 $title=Fun::toGet('title'); //真實姓名 if($user=='' or $pass==''){exit('Error:'.__LINE__.', 登入名或密碼不能為空!');} $title=($title=='') ? $user : $title; if(!Fun::Preg("^[a-zA-Z0-9]{3,16}$",'chk',$user)){exit('Error:'.__LINE__.', 登入名稱只能有英文和數字組成,並且長度範圍是3~16');} if(!Fun::Preg("^[a-zA-Z0-9._]{3,16}$",'chk',$pass)){exit('Error:'.__LINE__.', 登入密碼只能有英文,數字和底線組成,並且長度範圍是3~16');} try{ $RootObj= new COM('RTXSAPIRootObj.RTXSAPIRootObj'); $RootObj -> ServerIP= '127.0.0.1'; $RootObj -> ServerPort= '8006'; $UserManagerObj= $RootObj -> UserManager; if(($UserManagerObj -> IsUserExist($user))===TRUE){ $UserManagerObj -> SetUserPwd($user,$pass); //设置用户密码 $UserManagerObj -> SetUserBasicInfo($user,$title,0,'','','',0); echo '200 ok'; }else{ exit('Error:'.__LINE__.',用戶不存在!'); } }catch(Exception $e){ echo '
',Var_Dump($e->getMessage()),'
'; Die(); } } /** 交流: QQ群:223494678 參數: key:必填,API密鈅 action:必填,操作指令 user:必填,只能由英文和數字組成,長度不能小於3 pass:必填,只能由英文,數字和底線組成,長度不能小於3 title:選填,用戶真實姓名,可以用中文 用法: $a=file_get_contents('http://10.20.30.40:8012/_api.php?key=d6904e27b5c274b1d6acaadda88ec131&action=del&user=xxx'); echo '
',var_dump($a),'
'; /**/ function _Del(){ $user=Fun::toGet('user'); //登入名 $pass=Fun::toGet('pass'); //登入密碼 $title=Fun::toGet('title'); //真實姓名 if($user=='' or $pass==''){exit('Error:'.__LINE__.', 登入名或密碼不能為空!');} $title=($title=='') ? $user : $title; if(!Fun::Preg("^[a-zA-Z0-9]{3,16}$",'chk',$user)){exit('Error:'.__LINE__.', 登入名稱只能有英文和數字組成,並且長度範圍是3~16');} if(!Fun::Preg("^[a-zA-Z0-9._]{3,16}$",'chk',$pass)){exit('Error:'.__LINE__.', 登入密碼只能有英文,數字和底線組成,並且長度範圍是3~16');} try{ $RootObj= new COM('RTXSAPIRootObj.RTXSAPIRootObj'); $RootObj -> ServerIP= '127.0.0.1'; $RootObj -> ServerPort= '8006'; $UserManagerObj= $RootObj -> UserManager; if(($UserManagerObj -> IsUserExist($user))===TRUE){ $UserManagerObj -> DeleteUser($user); echo '200 ok'; }else{ exit('Error:'.__LINE__.',用戶不存在!'); } }catch(Exception $e){ echo '
',Var_Dump($e->getMessage()),'
'; Die(); } } /** 交流: QQ群:223494678 參數: key:必填,API密鈅 action:必填,操作指令 uid:必填,RTX號碼,不可以是登入名 did:必填,所屬部門的id 用法: $a=file_get_contents('http://10.20.30.40:8012/_api.php?key=d6904e27b5c274b1d6acaadda88ec131&action=setdept&uid=9534&did=18'); echo '
',var_dump($a),'
'; /**/ function _Setdept(){ $uid=Fun::toGet('uid'); //RTX號碼 $did=Fun::toGet('did'); //所屬部門的id if(!is_numeric($uid) or $uid<1){exit('Error:'.__LINE__.', 只能填寫被修改者的RTX號碼,不可以填寫登入名!');} if(!is_numeric($did) or $did<1){exit('Error:'.__LINE__.', 只能填寫所屬部門的ID值,不可以填寫部門名稱!');} $ACC=new Access('../db/rtxdb.mdb','',''); $ACC->num_rows("update RTX_DeptUser set DeptID = {$did} where UserID={$uid}"); echo '200 ok'; die(); } /** 交流: QQ群:223494678 參數: key:必填,API密鈅 action:必填,操作指令 用法: $a=file_get_contents('http://10.20.30.40:8012/_api.php?key=d6904e27b5c274b1d6acaadda88ec131&action=userlist'); echo '
',var_dump(json_decode($a,TRUE)),'
'; die(); /**/ function _Userlist(){ $ACC=new Access('../db/rtxdb.mdb','',''); $a=$ACC->getlist("SELECT a.ID,a.UserName,a.Name,a.Gender,a.Mobile,a.Email,a.Phone,a.UserVersion,b.DeptID FROM `SYS_User` AS a,RTX_DeptUser AS b WHERE (a.AccountState=0 OR a.AccountState IS NULL) AND b.UserId=a.ID ORDER BY a.ID DESC"); foreach($a as $k=>$v){ if(!isset($a[$k]['Name']) or $a[$k]['Name']==''){continue;} $a[$k]['Name']=iconv('big5','UTF-8',$a[$k]['Name']); }unset($k,$v); header('Content-type: application/json; charset=UTF-8'); echo json_encode($a); die(); } /** 交流: QQ群:223494678 參數: key:必填,API密鈅 action:必填,操作指令 用法: $a=file_get_contents('http://10.20.30.40:8012/_api.php?key=d6904e27b5c274b1d6acaadda88ec131&action=deptlist'); echo '
',var_dump(json_decode($a,TRUE)),'
'; die(); /**/ function _Deptlist(){ $ACC=new Access('../db/rtxdb.mdb','',''); $a=$ACC->getlist("SELECT DeptID,PDeptID,DeptName,SortID FROM `RTX_Dept` ORDER BY PDeptID ASC,SortID ASC"); foreach($a as $k=>$v){ if(!isset($a[$k]['DeptName']) or $a[$k]['DeptName']==''){continue;} $a[$k]['DeptName']=iconv('big5','UTF-8',$a[$k]['DeptName']); }unset($k,$v); header('Content-type: application/json; charset=UTF-8'); echo json_encode($a); die(); } /** 交流: QQ群:223494678 參數: key:必填,API密鈅 action:必填,操作指令 user:必填,某人的登入名 用法: $a=file_get_contents('http://10.20.30.40:8012/_api.php?key=d6904e27b5c274b1d6acaadda88ec131&action=getstatus&user=7di'); echo $a; die(); /**/ function _Getstatus(){ $user = Fun::toGet('user'); $ObjApi= new COM('Rtxserver.rtxobj'); $objProp= new COM('Rtxserver.collection'); $ObjApi->Name = 'SysTools'; $objProp->Add('Username',$user); $r = @$ObjApi->Call2(0x2001,$objProp); echo($r); unset($user,$r,$objProp,$ObjApi); die(); } /** 交流: QQ群:223494678 參數: key:必填,API密鈅 action:必填,操作指令 status:必填,狀態值['offline','online','away'] 用法: $a=file_get_contents('http://10.20.30.40:8012/_api.php?key=d6904e27b5c274b1d6acaadda88ec131&action=getuserbystatus&status=away'); echo $a; die(); /**/ function _Getuserbystatus(){ $status=Fun::toGet('status'); $status=($status=='') ? 'online' : strtolower(trim($status)); if(!in_array($status,array('offline','online','away'))){ exit('Error:'.__LINE__.', status is not in offline online away!'); } $RootObj= new COM("RTXSAPIRootObj.RTXSAPIRootObj"); $RootObj -> ServerIP= '127.0.0.1'; $RootObj -> ServerPort= '8006'; $r = $RootObj->QueryUsersByState($status); echo ($r); unset($status,$r,$RootObj); die(); } /** 交流: QQ群:223494678 參數: key:必填,API密鈅 action:必填,操作指令 to:必填,誰要接收(多個人名之間要用分號分隔) tit:必填,通知的標題 msg:必填,通知的正文 tim:必填,通知顯示多久 用法: $msg=(iconv('UTF-8','big5','這是測息,正文!')); $tit=iconv('UTF-8','big5','這是標題!'); $a=file_get_contents('http://10.20.30.40:8012/_api.php?key=d6904e27b5c274b1d6acaadda88ec131&action=sendtz&tit='.$tit.'&msg='.$msg.'&to=7di;benhuang'); echo $a; die(); /**/ function _Sendtz(){ $to=Fun::toGet('to'); //誰要接收 $tit=Fun::toGet('tit'); //通知的標題 $msg=Fun::toGet('msg'); //通知的正文 $tim=Fun::toGet('tim'); //通知顯示多久 $tim = (strlen($tim) == 0 or !is_numeric($tim)) ? 100000 : $tim; if($to=='' or $msg=='' or $tit==''){ exit('Error:'.__LINE__.', 通知標題,正文,接收者均不可為空!'); } $RootObj= new COM("RTXSAPIRootObj.RTXSAPIRootObj"); $RootObj -> ServerIP= '127.0.0.1'; $RootObj -> ServerPort= '8006'; $RootObj->SendNotify($to,$tit,$tim,$msg); //txtReceivers.Text, txtTitle.Text, CInt(txtTime.Text), txtContent.Text unset($RootObj,$to,$tit,$msg,$tim); echo '200 ok'; die(); } /** 交流: QQ群:223494678 參數: key:必填,API密鈅 action:必填,操作指令 user:必填,發送者登入名 pass:必填,發送者登入密碼 to:必填,誰要接收(多個人名之間要用分號分隔) msg:必填,通知的正文 用法: $msg=(iconv('UTF-8','big5','這是測息,正文!')); $a=file_get_contents('http://10.20.30.40:8012/_api.php?key=d6904e27b5c274b1d6acaadda88ec131&action=sendim&user=admin&pass=bossadm.com.tw&to=7di;benhuang&msg='.$msg); echo $a; die(); /**/ function _Sendim(){ $user=Fun::toGet('user'); $pass=Fun::toGet('pass'); $to=Fun::toGet('to'); $msg=Fun::toGet('msg'); if($to=='' or $msg=='' or $user=='' or $pass==''){ exit('Error:'.__LINE__.', 每個參數均不可為空!'); } if(!Fun::Preg("^[a-zA-Z0-9]{3,16}$",'chk',$user)){exit('Error:'.__LINE__.', 登入名稱只能有英文和數字組成,並且長度範圍是3~16');} if(!Fun::Preg("^[a-zA-Z0-9._]{3,16}$",'chk',$pass)){exit('Error:'.__LINE__.', 登入密碼只能有英文,數字和底線組成,並且長度範圍是3~16');} $RootObj= new COM('RTXSAPIRootObj.RTXSAPIRootObj'); $RootObj -> ServerIP= '127.0.0.1'; $RootObj -> ServerPort= '8006'; $sid=Fun::guid(); $RootObj->SendIM($user,$pass,$to,$msg,$sid); echo '200 ok'; unset($user,$pass,$to,$msg,$sid,$RootObj); die(); }

Friends who are interested in RTX can join my QQ group to discuss together. The QQ group number is 223494678

What development languages ​​are supported for secondary development of RTX software?

The RTX API interface is suitable for any development language and platform that supports COM standards on the Windows platform (VB, VC++, ASP, JAVA, C#, PB, Delphi, LotusScript, etc.).
Reference: rtx.qq.com/...ok.CHM

Secondary development of Tencent RTX JAVA

Does the rtx client receive it?

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/852746.htmlTechArticleTencent RTX API development, opening a skylight for RTX, rtx Many people may not have heard of the RTX software. Let me briefly explain that this software is an internal chat software developed by Tencent for enterprises. It serves...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn