


Tencent RTX API development, open a skylight for RTX, rtx_PHP tutorial
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
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
Does the rtx client receive it?

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Alipay PHP...

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

The enumeration function in PHP8.1 enhances the clarity and type safety of the code by defining named constants. 1) Enumerations can be integers, strings or objects, improving code readability and type safety. 2) Enumeration is based on class and supports object-oriented features such as traversal and reflection. 3) Enumeration can be used for comparison and assignment to ensure type safety. 4) Enumeration supports adding methods to implement complex logic. 5) Strict type checking and error handling can avoid common errors. 6) Enumeration reduces magic value and improves maintainability, but pay attention to performance optimization.

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.
