騰訊rtx的api開發,給rtx開個天窗,rtx    好多人可能沒聽說rtx這個軟件,在此我簡單說明一下,這個軟件是騰訊為企業開發的一個內部聊天軟件,服務端不是在騰訊那邊,而是需要企業自己安裝到自己公司內部的服務器上,以供企業內部員工交流使用,功能和qq差不多,只是比qq弱一點罷了.
    嚴格說起來,其實rtx是有提供api接口的,只是不大太好,最近公司對此有需要,所以我就重寫了一下這個api.另外我重寫的主要原因是rtx自帶的api遇到中文會亂碼,而且還有很多雜七雜八的問題,上網搜結果發現關於rtx的api討論話題極少.估計是因為大家對這個軟件的關注程度不高的原因吧.
    試想一下,其實網站交互的時候我們除了可以用網站發郵件或手機簡訊之外還可以發送即時消息到rtx上,讓公司內部的員工能夠及時瞭解到網站訪問者的需求,爲了達到這個目的,因此我重寫了我們公司內部的rtx的api,重寫之後的api能實現新增rtx用戶,修改用戶資料,刪除用戶,獲取所有的用戶列表,根據狀態獲取某些用戶,獲取公司內部的組織架構,發送即時通知給某些用戶,發送即時消息給某些用戶等等,下邊我就直接上代碼了:
 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 $uidgetlist(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();} 
 對rtx有興趣的朋友可以加我的qq群一起討論,qq群號是223494678
rtx软件二次开发支持什开发语言?
rtx api接口适合于windows平台上支持com标准的任何开发语言和平台(vb、vc++、asp、java、c#、pb、delphi、lotusscript等)。
参考资料:rtx.qq.com/...ok.chm
腾讯通rtx java的二次开发
rtx客户端接收吗?
http://www.bkjia.com/phpjc/852746.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/852746.htmltecharticle騰訊rtx的api開發,給rtx開個天窗,rtx 好多人可能沒聽說rtx這個軟件,在此我簡單說明一下,這個軟件是騰訊為企業開發的一個內部聊天軟件,服...
   
 
   