Tenim.php 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use app\utils\RedisUtil;
  5. use think\Request;
  6. use getusersig\getusersig;
  7. use tencentim\tencentim;
  8. use think\Db;
  9. /**
  10. * 腾讯im接口
  11. */
  12. class Tenim extends Api
  13. {
  14. protected $noNeedLogin = ['*'];
  15. protected $noNeedRight = ['*'];
  16. protected $prefix = 'xl';
  17. public function test() {
  18. $groupinfo = $this->getGroupInfo("112");
  19. print_r($groupinfo);
  20. exit;
  21. // 获取所有派对信息
  22. $partyList = \app\common\model\Party::field("id,user_id,party_name")->where(["status"=>1])->order("id","asc")->select();
  23. foreach($partyList as $k => $v) {
  24. if($k>=140 && $k<180) {
  25. $groupinfo = $this->getGroupInfo((string)$v["id"]);
  26. print_r($groupinfo);
  27. // $groupinfo = json_encode($groupinfo);
  28. // Db::table("hx_aaaa")->insert(["party_id"=>$v["id"],"user_id"=>$v["user_id"],"party_name"=>$v["party_name"],"json"=>$groupinfo]);
  29. }
  30. }
  31. exit;
  32. // $this->success("",$partyList);
  33. }
  34. public function loginoutim($uid){
  35. /*
  36. * https://console.tim.qq.com/v4/im_open_login_svc/kick?sdkappid=88888888&identifier=admin&usersig=xxx&random=99999999&contenttype=json
  37. */
  38. $random = rand(10000000, 99999999);
  39. $usersig = $this->usersig("administrator");
  40. // 获取配置信息
  41. $config = config("tencent_im");
  42. $url = "https://console.tim.qq.com/v4/im_open_login_svc/kick";
  43. $url .= "?sdkappid=" . $config["sdkappid"];
  44. $url .= "&identifier=administrator";
  45. $url .= "&usersig=" . $usersig;
  46. $url .= "&random=" . $random;
  47. $url .= "&contenttype=json";
  48. $data = [
  49. 'Identifier' => "".$uid."",
  50. ];
  51. $rs = curl_post($url,json_encode($data));
  52. //dump($rs);
  53. // exit;
  54. }
  55. public function selectstatus(){
  56. /*
  57. * https://console.tim.qq.com/v4/openim/query_online_status?sdkappid=88888888&identifier=admin&usersig=xxx&random=99999999&contenttype=json
  58. */
  59. $random = rand(10000000, 99999999);
  60. $usersig = $this->usersig("administrator");
  61. // 获取配置信息
  62. $config = config("tencent_im");
  63. $url = "https://console.tim.qq.com/v4/openim/query_online_status";
  64. $url .= "?sdkappid=" . $config["sdkappid"];
  65. $url .= "&identifier=administrator";
  66. $url .= "&usersig=" . $usersig;
  67. $url .= "&random=" . $random;
  68. $url .= "&contenttype=json";
  69. $data = [
  70. 'To_Account' => ["34"],
  71. ];
  72. $rs = curl_post($url,json_encode($data));
  73. //$rs = curl_post($url,'{"IsNeedDetail":1,"To_Account":["32"]}');
  74. dump($rs);
  75. exit;
  76. }
  77. /**
  78. * 创建im群组
  79. */
  80. public function createIMGroup() {
  81. $random = rand(10000000,99999999);
  82. $usersig = $this->usersig("administrator");
  83. // 获取配置信息
  84. $config = config("tencent_im");
  85. $url = "https://console.tim.qq.com/v4/group_open_http_svc/create_group";
  86. $url .= "?sdkappid=".$config["sdkappid"];
  87. $url .= "&identifier=administrator";
  88. $url .= "&usersig=".$usersig;
  89. $url .= "&random==".$random;
  90. $url .= "&contenttype=json";
  91. $tencentObj = new tencentim($url);
  92. // 获取群im信息
  93. $imInfo = Db::table("hx_aaaa")->where(["party_id"=>112])->select();
  94. if($imInfo) foreach($imInfo as $k => $v) {
  95. // if($k>=160 && $k<200) {
  96. $grouparr = json_decode($v["json"], true);
  97. $grouparr = $grouparr["GroupInfo"][0];
  98. $AppDefinedData = $grouparr["AppDefinedData"];
  99. $data = [];
  100. $data["Owner_Account"] = (string)$v["user_id"];
  101. $data["Type"] = "AVChatRoom";
  102. $data["GroupId"] = (string)$v["party_id"];
  103. $data["Name"] = $this->substr((string)$v["party_name"],0,7);
  104. $AppDefinedDataNew = [
  105. [
  106. "Key" => "roomInfo",
  107. "Value" => "sssssss"
  108. ],
  109. [
  110. "Key" => "seat0",
  111. "Value" => '{"mute":false,"status":0,"user":""}'
  112. ],
  113. [
  114. "Key" => "seat1",
  115. "Value" => $AppDefinedData[2]["Value"]
  116. ],
  117. [
  118. "Key" => "seat2",
  119. "Value" => $AppDefinedData[3]["Value"]
  120. ],
  121. [
  122. "Key" => "seat3",
  123. "Value" => $AppDefinedData[4]["Value"]
  124. ],
  125. [
  126. "Key" => "seat4",
  127. "Value" => $AppDefinedData[5]["Value"]
  128. ],
  129. [
  130. "Key" => "seat5",
  131. "Value" => $AppDefinedData[6]["Value"]
  132. ],
  133. [
  134. "Key" => "seat6",
  135. "Value" => $AppDefinedData[7]["Value"]
  136. ],
  137. [
  138. "Key" => "seat7",
  139. "Value" => $AppDefinedData[8]["Value"]
  140. ],
  141. [
  142. "Key" => "seat8",
  143. "Value" => $AppDefinedData[9]["Value"]
  144. ]
  145. ];
  146. $data["AppDefinedData"] = json_encode($AppDefinedDataNew);
  147. $groupInfo = $tencentObj->toSend($data);
  148. if($groupInfo["ActionStatus"] != 'OK') {
  149. echo $v["party_id"];
  150. break;
  151. }
  152. // }
  153. }
  154. print_r($groupInfo);exit;
  155. }
  156. public function substr(string $string, int $start, int $length = null)
  157. {
  158. return mb_substr($string, $start, $length, 'UTF-8');
  159. }
  160. /**
  161. * 更新房间信息
  162. */
  163. public function updateRoomInfo() {
  164. $random = rand(10000000, 99999999);
  165. $usersig = $this->usersig("administrator");
  166. // 获取配置信息
  167. $config = config("tencent_im");
  168. $url = "https://console.tim.qq.com/v4/group_open_http_svc/modify_group_base_info";
  169. $url .= "?sdkappid=" . $config["sdkappid"];
  170. $url .= "&identifier=administrator";
  171. $url .= "&usersig=" . $usersig;
  172. $url .= "&random=" . $random;
  173. $url .= "&contenttype=json";
  174. $tencentObj = new tencentim($url);
  175. // 获取群im信息
  176. $imInfo = Db::table("hx_aaaa")->select();
  177. if($imInfo) foreach($imInfo as $k => $v) {
  178. if($k>=120 && $k<180) {
  179. $grouparr = json_decode($v["json"], true);
  180. $groupsites = $grouparr["GroupInfo"];
  181. // 循环房间
  182. if ($groupsites) foreach ($groupsites as $k => $v) {
  183. // 循环座位
  184. $data = [];
  185. foreach ($v["AppDefinedData"] as $m => $n) {
  186. // 解析字段信息
  187. $siteInfo = json_decode($n["Value"], true);
  188. $data["AppDefinedData"][] = [
  189. "Key" => $n["Key"],
  190. "Value" => $n["Value"],
  191. ];
  192. }
  193. if (!empty($data)) {
  194. $data["GroupId"] = $v["GroupId"];
  195. $res = $tencentObj->toSend($data);
  196. } else {
  197. echo "error!";
  198. break;
  199. }
  200. }
  201. }
  202. }
  203. print_r($res);
  204. exit;
  205. }
  206. /**
  207. * 获取群组信息
  208. */
  209. public function getGroupInfo($party_id) {
  210. $random = rand(10000000,99999999);
  211. $usersig = $this->usersig("administrator");
  212. // 获取配置信息
  213. $config = config("tencent_im");
  214. $url = "https://console.tim.qq.com/v4/group_open_http_svc/get_group_info";
  215. $url .= "?sdkappid=".$config["sdkappid"];
  216. $url .= "&identifier=administrator";
  217. $url .= "&usersig=".$usersig;
  218. $url .= "&random==".$random;
  219. $url .= "&contenttype=json";
  220. $tencentObj = new tencentim($url);
  221. $data = [];
  222. $data["GroupIdList"] = [$party_id];
  223. $data["ResponseFilter"] = ["AppDefinedDataFilter_Group"=>[]];
  224. $groupInfo = $tencentObj->toSend($data);
  225. return $groupInfo;
  226. }
  227. /**
  228. * 获取用户所加入的群组
  229. */
  230. public function getJoindGroupList($user_id) {
  231. $random = rand(10000000,99999999);
  232. $usersig = $this->usersig("administrator");
  233. // 获取配置信息
  234. $config = config("tencent_im");
  235. $url = "https://console.tim.qq.com/v4/group_open_http_svc/get_joined_group_list";
  236. $url .= "?sdkappid=".$config["sdkappid"];
  237. $url .= "&identifier=administrator";
  238. $url .= "&usersig=".$usersig;
  239. $url .= "&random=".$random;
  240. $url .= "&contenttype=json";
  241. $tencentObj = new tencentim($url);
  242. $data = [];
  243. $data["Member_Account"] = $user_id;
  244. $data["WithHugeGroups"] = 1;
  245. $data["GroupType"] = 'AVChatRoom';
  246. $data["ResponseFilter"] = ["GroupBaseInfoFilter" => ['GroupId'] ];
  247. $groupInfo = $tencentObj->toSend($data);
  248. // \app\common\model\Test::update(["content"=>json_encode($groupInfo)],["id"=>1]);
  249. return $groupInfo;
  250. }
  251. //"https:\/\/console.tim.qq.com\/v4\/group_open_http_svc\/get_joined_group_list?sdkappid=1400458032&identifier=administrator&usersig=eJyrVgrxCdYrSy1SslIy0jNQ0gHzM1NS80oy0zLBwqamUNHilOzEgoLMFCUrQxMDAxNTCwNjI4hMakVBZlEqUNzU1NTIwMAAIlqSmQsSMzO0MDY0NDOwhJqSmQ40NNwowsvMzzXKw8wsLNIwRr9S28giPKjMPSkpKLPcLcfFPd3TO7swz9fXOdLTVqkWADrXLzo_&random=73931990&contenttype=json"
  252. // /**
  253. // * 删除群成员
  254. // */
  255. // public function delMemberFromGroup($user_id,$party_id) {
  256. // $random = rand(10000000,99999999);
  257. // $usersig = $this->usersig($user_id);
  258. // // 获取配置信息
  259. // $config = config("tencent_im");
  260. // $url = "https://console.tim.qq.com/v4/group_open_http_svc/delete_group_member";
  261. // $url .= "?sdkappid=".$config["sdkappid"];
  262. // $url .= "&identifier=administrator";
  263. // $url .= "&usersig=".$usersig;
  264. // $url .= "&random=".$random;
  265. // $url .= "&contenttype=json";
  266. // $tencentObj = new tencentim($url);
  267. // $data = [];
  268. // $data["GroupId"] = $party_id;
  269. // $data["Silence"] = 1;
  270. // $data["MemberToDel_Account"] = [$user_id];
  271. // $res = $tencentObj->toSend($data);
  272. // \app\common\model\Test::update(["content"=>json_encode($res)],["id"=>1]);
  273. // return $res;
  274. // }
  275. /**
  276. * 设置管理员(自定义消息)
  277. */
  278. public function setImManage($manage_user_id,$party_id,$status=0) {
  279. $random = rand(10000000,99999999);
  280. $usersig = $this->usersig("administrator");
  281. // 获取配置信息
  282. $config = config("tencent_im");
  283. $url = "https://console.tim.qq.com/v4/group_open_http_svc/modify_group_base_info";
  284. $url .= "?sdkappid=".$config["sdkappid"];
  285. $url .= "&identifier=administrator";
  286. $url .= "&usersig=".$usersig;
  287. $url .= "&random=".$random;
  288. $url .= "&contenttype=json";
  289. $tencentObj = new tencentim($url);
  290. // 获取群组信息
  291. $groupInfo = $this->getGroupInfo($party_id);
  292. if($groupInfo["GroupInfo"][0]["ErrorCode"] > 0) return false;
  293. $roomInfoData = $groupInfo["GroupInfo"][0]["AppDefinedData"];
  294. $roomInfo = [];
  295. if($roomInfoData) foreach($roomInfoData as $k => $v) {
  296. if($v["Key"] == "roomInfo") $roomInfo = $v["Value"];
  297. }
  298. $roomInfo = json_decode($roomInfo,true);
  299. // 更新的信息
  300. if(isset($roomInfo["managers"])) {
  301. if(!$roomInfo["managers"]) $roomInfo["managers"] = [];
  302. }
  303. if ($status==1){
  304. array_push($roomInfo["managers"],$manage_user_id);
  305. $roomInfo["managers"] = array_unique($roomInfo["managers"]);
  306. }else{
  307. foreach ($roomInfo["managers"] as $k => $v){
  308. if ($v == $manage_user_id) {
  309. unset($roomInfo["managers"][$k]);
  310. break;
  311. }
  312. }
  313. }
  314. $data = [];
  315. $data["GroupId"] = $party_id;
  316. $data["AppDefinedData"][0] = [
  317. "Key" => "roomInfo",
  318. "Value" => json_encode($roomInfo),
  319. // "Value" => json_encode(json_decode('{"bg":"","cover":"","isScreen":0,"managers":["14","29"],"needRequest":0,"onMode":2,"ownerId":"55","ownerName":"过户手续","pwd":"","roomName":"告白气球~满眼是✨✨","seatSize":9,"silencers":[]}',true)),
  320. ];
  321. if(isset($roomInfo["ownerId"]) && isset($roomInfo["roomName"])) {
  322. $tencentObj->toSend($data);
  323. }
  324. }
  325. /**
  326. * 强制下线
  327. */
  328. public function downSite($user_id,$groupsites) {
  329. $random = rand(10000000,99999999);
  330. $usersig = $this->usersig("administrator");
  331. // 获取配置信息
  332. $config = config("tencent_im");
  333. $url = "https://console.tim.qq.com/v4/group_open_http_svc/modify_group_base_info";
  334. $url .= "?sdkappid=".$config["sdkappid"];
  335. $url .= "&identifier=administrator";
  336. $url .= "&usersig=".$usersig;
  337. $url .= "&random=".$random;
  338. $url .= "&contenttype=json";
  339. $tencentObj = new tencentim($url);
  340. // 先更新下麦时间
  341. $update = [];
  342. $update["offsite_time"] = time();
  343. $update["status"] = 2;
  344. \app\common\model\UserOnsiteTime::update($update,["user_id"=>$user_id,"status"=>1]);
  345. // 循环房间
  346. if($groupsites) foreach($groupsites as $k => $v) {
  347. // 循环座位
  348. $data = [];
  349. foreach($v["AppDefinedData"] as $m => $n) {
  350. // 解析字段信息
  351. $siteInfo = json_decode($n["Value"],true);
  352. if($m != 0 && isset($siteInfo["status"]) && $siteInfo["status"] == 1 && isset($siteInfo["status"]) && $siteInfo["user"] == $user_id) {
  353. $data["AppDefinedData"][] = [
  354. "Key" => $n["Key"],
  355. "Value" => '{"mute":false,"status":0,"user":""}',
  356. ];
  357. }
  358. }
  359. if(!empty($data)) {
  360. $data["GroupId"] = $v["GroupId"];
  361. return $tencentObj->toSend($data);
  362. }
  363. }
  364. }
  365. /**
  366. * 踢出房间内所有用户
  367. */
  368. public function outMemberFromRoom($party_id) {
  369. if($party_id <= 0) return false;
  370. $message = [];
  371. $message["type"] = "91";
  372. $message["content"] = "房间已被管理员关闭!详情请联系客服!";
  373. $msgData = [];
  374. $msgData["version"] = "1.0";
  375. $msgData["action"] = 301;
  376. $msgData["command"] = "";
  377. $msgData["message"] = json_encode($message);
  378. $random = rand(10000000,99999999);
  379. $usersig = $this->usersig("administrator");
  380. // 获取配置信息
  381. $config = config("tencent_im");
  382. $url = "https://console.tim.qq.com/v4/group_open_http_svc/send_group_msg";
  383. $url .= "?sdkappid=".$config["sdkappid"];
  384. $url .= "&identifier=administrator";
  385. $url .= "&usersig=".$usersig;
  386. $url .= "&random=".$random;
  387. $url .= "&contenttype=json";
  388. $tencentObj = new tencentim($url);
  389. $data = [];
  390. $data["GroupId"] = $party_id;
  391. $data["Random"] = rand(1000000,9999999);
  392. $data["MsgBody"][] = [
  393. "MsgType" => "TIMCustomElem",
  394. "MsgContent" => [
  395. "Data"=> json_encode($msgData)
  396. ],
  397. ];
  398. $tencentObj->toSend($data);
  399. }
  400. /**
  401. * 获取usersig签名
  402. */
  403. public function getUsersig() {
  404. $user_id = $this->auth->id;
  405. $this->success("获取成功!",$this->usersig($user_id));
  406. }
  407. /**
  408. * 获取usersig签名-具体操作
  409. */
  410. private function usersig($user_id) {
  411. // 获取配置信息
  412. $config = config("tencent_im");
  413. $usersigObj = new getusersig($config["sdkappid"],$config["key"]);
  414. $usersig = $usersigObj->genUserSig($user_id);
  415. return $usersig;
  416. }
  417. /**
  418. * 强制下麦
  419. */
  420. public function updateSiteInfo() {
  421. $user_id = $this->request->request("user_id");// 用户ID
  422. if(!$user_id) $this->error("参数缺失!");
  423. // 更新用户在线状态为离线
  424. \app\common\model\User::update(["is_online"=>0],["id"=>$user_id]);
  425. // \app\common\model\User::update(["is_live"=>0],["id"=>$user_id]);
  426. \app\common\model\Party::update(["is_online"=>0],["user_id"=>$user_id]);
  427. // 获取用户所在群信息
  428. $groupids = $this->getJoindGroupList($user_id);
  429. if($groupids["ErrorCode"] == 0) {
  430. $grouplist = $groupids["GroupIdList"];
  431. $groupsites = [];
  432. if($grouplist) foreach($grouplist as $k => $v) {
  433. // 获取群组消息
  434. $groupInfo = $this->getGroupInfo($v["GroupId"]);
  435. if($groupInfo["ErrorCode"] == 0) $groupsites[] = $groupInfo["GroupInfo"][0];
  436. // 踢出用户在线组
  437. RedisUtil::getInstance('online',$v["GroupId"])->HDel($user_id);
  438. }
  439. // 强制下麦
  440. $this->downSite($user_id,$groupsites);
  441. }
  442. $this->success("状态更新成功!");
  443. }
  444. /**
  445. * 更新麦位前四
  446. */
  447. public function updatePosition($user_id,$party_id) {
  448. // 获取用户头像
  449. $userInfo = \app\common\model\User::field("avatar")->where(["id"=>$user_id])->find();
  450. $userAvatar = isset($userInfo["avatar"])?$userInfo["avatar"]:"";
  451. $redisData = RedisUtil::getInstance('party',$party_id)->get();
  452. if(!$redisData) {
  453. return true;
  454. }
  455. $partyInfo = json_decode($redisData,true);
  456. // 遍历已有头像
  457. $partyuser = isset($partyInfo["party_user"])?$partyInfo["party_user"]:"";
  458. if(is_array($partyuser)) foreach($partyuser as $k => $v) if($v === $userAvatar) unset($partyInfo["party_user"][$k]);
  459. RedisUtil::getInstance('party',$party_id)->set(json_encode($partyInfo));
  460. }
  461. /**
  462. * 取消排麦
  463. */
  464. public function cancelLineUp($user_id,$party_id) {
  465. if (!$party_id || !$user_id) {
  466. return false;
  467. }
  468. $data=unserialize(RedisUtil::getInstance('party_lineup')->hGet($party_id));
  469. // 更改红点排麦数量
  470. $num = 0;
  471. $send = false;
  472. if($data) foreach($data as $k => $v) {
  473. if($v["user_id"] == $user_id) {
  474. $send = true;
  475. unset($data[$k]);
  476. break;
  477. }
  478. }
  479. RedisUtil::getInstance('party_lineup')->hSet($party_id,serialize($data));
  480. if($send) {
  481. is_array($data) && $num = count($data);
  482. $random = rand(10000000,99999999);
  483. $usersig = $this->usersig("administrator");
  484. // 获取配置信息
  485. $config = config("tencent_im");
  486. $url = "https://console.tim.qq.com/v4/group_open_http_svc/send_group_msg";
  487. $url .= "?sdkappid=".$config["sdkappid"];
  488. $url .= "&identifier=administrator";
  489. $url .= "&usersig=".$usersig;
  490. $url .= "&random=".$random;
  491. $url .= "&contenttype=json";
  492. $tencentObj = new tencentim($url);
  493. $data = [];
  494. $data["GroupId"] = $party_id;
  495. $data["Random"] = rand(1000000,9999999);
  496. $message = [
  497. "message" => json_encode(["type"=>23,"content"=>$num]),
  498. "version" => "1.0",
  499. "action" => 301,
  500. "command" => ""
  501. ];
  502. $data["MsgBody"][] = [
  503. "MsgType" => "TIMCustomElem",
  504. "MsgContent" => [
  505. "Data"=> json_encode($message)
  506. ],
  507. ];
  508. $tencentObj->toSend($data);
  509. }
  510. }
  511. //trtc_callback,直播callback
  512. //https://cloud.tencent.com/document/product/647/51586#eventId
  513. /*
  514. 2021-12-24 15:34:22 start2:{
  515. "EventGroupId": 1,
  516. "EventType": 103,
  517. "CallbackTs": 1640331262241,
  518. "EventInfo": {
  519. "RoomId": 1604,
  520. "EventTs": 1640331262,
  521. "EventMsTs": 1640331262238,
  522. "UserId": "26",
  523. "Role": 20,
  524. "TerminalType": 2,
  525. "UserType": 3,
  526. "Reason": 1
  527. }
  528. }
  529. 2021-12-24 15:34:22 start2:{
  530. "EventGroupId": 1,
  531. "EventType": 101,
  532. "CallbackTs": 1640331262247,
  533. "EventInfo": {
  534. "RoomId": 1604,
  535. "EventTs": 1640331262,
  536. "EventMsTs": 1640331262238,
  537. "UserId": "26"
  538. }
  539. }
  540. 2021-12-24 15:34:55 start2:{
  541. "EventGroupId": 1,
  542. "EventType": 102,
  543. "CallbackTs": 1640331295244,
  544. "EventInfo": {
  545. "RoomId": 1604,
  546. "EventTs": 1640331295,
  547. "EventMsTs": 1640331295239
  548. }
  549. }
  550. 2021-12-24 15:34:55 start2:{
  551. "EventGroupId": 1,
  552. "EventType": 104,
  553. "CallbackTs": 1640331295244,
  554. "EventInfo": {
  555. "RoomId": 1604,
  556. "EventTs": 1640331295,
  557. "EventMsTs": 1640331295239,
  558. "UserId": "26",
  559. "Role": 20,
  560. "Reason": 1
  561. }
  562. }
  563. */
  564. public function trtc_callback(){
  565. $input = file_get_contents("php://input");
  566. filePut('start:'.$input,'callback.txt');
  567. /*$input = '{
  568. "EventGroupId": 1,
  569. "EventType": 104,
  570. "CallbackTs": 1640331295244,
  571. "EventInfo": {
  572. "RoomId": 1604,
  573. "EventTs": 1640331295,
  574. "EventMsTs": 1640331295239,
  575. "UserId": "26",
  576. "Role": 20,
  577. "Reason": 1
  578. }
  579. }';*/
  580. $input = json_decode($input,true);
  581. $roomId = $input['EventInfo']['RoomId'];
  582. //房间事件组
  583. if($input['EventGroupId'] == 1){
  584. if($input['EventType'] == 101){
  585. //创建房间,第一个进来的
  586. }elseif($input['EventType'] == 102){
  587. //解散房间,最后一个走的
  588. //没有UserId
  589. }elseif($input['EventType'] == 103){
  590. //进入房间,主播role=20 观众role=21
  591. $userId = $input['EventInfo']['UserId'];
  592. RedisUtil::getInstance('online',$roomId)->hSet($userId, $userId);
  593. // 记录在线用户在房间情况
  594. RedisUtil::getInstance('livingUser')->hSet($userId,$roomId);
  595. // 更新房间在线状态
  596. $partyInfo = $redis->get("party_" . $roomId);
  597. if ($partyInfo) {
  598. $partyInfo = json_decode($partyInfo, true);
  599. if ($partyInfo["is_online"] != 1) {
  600. $partyInfo["is_online"] = 1;
  601. $redis->set("party_" . $roomId, json_encode($partyInfo));
  602. \app\common\model\Party::update(["is_online" => 1], ["id" => $roomId]);
  603. }
  604. }
  605. // 更新房间在线状态
  606. $liveInfo = $redis->get("livebc_" . $roomId);
  607. if ($liveInfo) {
  608. $liveInfo = json_decode($liveInfo, true);
  609. if ($input['EventInfo']['Role'] == 20) {
  610. $liveInfo["is_online"] = 1;
  611. $redis->set("livebc_" . $roomId, json_encode($liveInfo));
  612. \app\common\model\Party::update(["is_online" => 1], ["id" => $roomId]);
  613. $rs_user = Db::name('user')->where('id',$userId)->update(['is_livebc'=>1]);
  614. }
  615. }
  616. }elseif($input['EventType'] == 104){
  617. //退出房间,主播role=20 观众role=21
  618. $userId = $input['EventInfo']['UserId'];
  619. RedisUtil::getInstance('online',$roomId)->HDel($userId);
  620. // 扣除在线用户在房间情况
  621. RedisUtil::getInstance('livingUser')->hDel($userId);
  622. // 更新房间在线状态
  623. $partyInfo = RedisUtil::getInstance('party',$roomId)->get();
  624. if ($partyInfo) {
  625. $partyInfo = json_decode($partyInfo, true);
  626. $memCount = count(RedisUtil::getInstance('online',$roomId)->hGetAll());
  627. if ($memCount <= 0) {
  628. $partyInfo["is_online"] = 0;
  629. RedisUtil::getInstance('party',$roomId)->set(json_encode($partyInfo));
  630. \app\common\model\Party::update(["is_online" => 0], ["id" => $roomId]);
  631. }
  632. }
  633. //
  634. $liveInfo = RedisUtil::getInstance('livebc',$roomId)->get();
  635. if ($liveInfo) {
  636. $liveInfo = json_decode($liveInfo, true);
  637. if($input['EventInfo']['Role'] == 20){
  638. $liveInfo["is_online"] = 0;
  639. RedisUtil::getInstance('livebc',$roomId)->set(json_encode($liveInfo));
  640. \app\common\model\Party::update(["is_online" => 0], ["id" => $roomId]);
  641. $rs_user = Db::name('user')->where('id',$userId)->update(['is_livebc'=>0]);
  642. }
  643. }
  644. }
  645. }elseif($input['EventGroupId'] == 2){
  646. }
  647. //结束
  648. echo json_encode(['code' => 0]);exit;
  649. }
  650. /**
  651. * 回调
  652. */
  653. public function callback() {
  654. $input = file_get_contents("php://input"); // 主题信息
  655. if(!$input) {
  656. echo '无数据';exit;
  657. }
  658. $input = json_decode($input,true);
  659. $CallbackCommand = $input["CallbackCommand"];
  660. switch ($CallbackCommand) {
  661. case 'State.StateChange': // 用户在线状态变更
  662. $info = $input["Info"];
  663. if($info["Action"] == "Login") { // 用户登录
  664. $loginToday = Db::name('user')->where('id',$info["To_Account"])->whereTime('onlinetime', 'today')->find();
  665. if ($loginToday){
  666. \app\common\model\User::update(["is_online"=>1,"onlinetime"=>time()],["id"=>$info["To_Account"]]);
  667. }else{
  668. \app\common\model\User::update(["is_online"=>1,"onlinetime"=>time()],["id"=>$info["To_Account"]]);
  669. }
  670. $res = [];
  671. $res["ActionStatus"] = "OK";
  672. $res["ErrorCode"] = 0;
  673. $res["ErrorInfo"] = "";
  674. echo json_encode($res);exit;
  675. } elseif($info["Action"] == "Logout" || $info["Action"] == "Disconnect") { // 用户退出 不需要管什么原因
  676. // 更新用户在线状态为离线
  677. $updateData['is_online'] = 0;
  678. $user = Db::name('user')->where('id',$info["To_Account"])->find();
  679. if (!empty($user)) {
  680. // 客户觉得实时判断导致在线用户数量过少,此处,不再根据IM处理用户在线状态,已在API父类中做接口访问频率处理用户在线状态
  681. // if ($user['gender'] == 1) {
  682. // $updateData['is_active'] = 0;
  683. // }
  684. }
  685. \app\common\model\User::update($updateData,["id"=>$info["To_Account"]]);
  686. //\app\common\model\User::update(["is_live"=>0],["id"=>$info["To_Account"]]);
  687. // 获取用户在派对直播间情况信息
  688. $livingUserPartyId = RedisUtil::getInstance('livingUser')->hGet($info["To_Account"]);
  689. if ($livingUserPartyId) {
  690. // 扣除在线用户在房间情况
  691. RedisUtil::getInstance('livingUser')->hDel( $info["To_Account"]);
  692. RedisUtil::getInstance('online',$livingUserPartyId)->HDel($info["To_Account"]);
  693. }
  694. // 获取用户所在群信息
  695. $groupids = $this->getJoindGroupList($info["To_Account"]);
  696. // \app\common\model\Test::update(["content"=>json_encode($groupids)],["id"=>1]);
  697. if($groupids["ErrorCode"] == 0) {
  698. $grouplist = $groupids["GroupIdList"];
  699. $groupsites = [];
  700. if($grouplist) foreach($grouplist as $k => $v) {
  701. // 获取群组消息
  702. $groupInfo = $this->getGroupInfo($v["GroupId"]);
  703. if($groupInfo["ErrorCode"] == 0) $groupsites[] = $groupInfo["GroupInfo"][0];
  704. // 踢出用户在线组
  705. RedisUtil::getInstance('online',$v["GroupId"])->HDel($info["To_Account"]);
  706. // 更新麦位前四
  707. $this->updatePosition($info["To_Account"],$v["GroupId"]);
  708. // 取消排麦
  709. $this->cancelLineup($info["To_Account"],$v["GroupId"]);
  710. // 房间状态变更
  711. $partyInfo = RedisUtil::getInstance('party',$v["GroupId"])->get();
  712. if($partyInfo) {
  713. $partyInfo = json_decode($partyInfo,true);
  714. $memCount = count(RedisUtil::getInstance('online',$v["GroupId"])->hGetAll());
  715. if($memCount <= 0) {
  716. $partyInfo["is_online"] = 0;
  717. RedisUtil::getInstance('party',$v["GroupId"])->set(json_encode($partyInfo));
  718. \app\common\model\Party::update(["is_online"=>0],["id"=>$v["GroupId"]]);
  719. }
  720. }
  721. $liveInfo = RedisUtil::getInstance('live',$v["GroupId"])->get();
  722. if($liveInfo) {
  723. $liveInfo = json_decode($liveInfo,true);
  724. $memCount = count(RedisUtil::getInstance('online',$v["GroupId"])->hGetAll());
  725. if($memCount <= 0) {
  726. $liveInfo["is_online"] = 0;
  727. RedisUtil::getInstance('live',$v["GroupId"])->set(json_encode($liveInfo));
  728. \app\common\model\Party::update(["is_online"=>0],["id"=>$v["GroupId"]]);
  729. }
  730. }
  731. }
  732. // 强制下麦
  733. print_r($this->downSite($info["To_Account"],$groupsites));
  734. }
  735. }
  736. break;
  737. // case 'Group.CallbackAfterNewMemberJoin': // 新成员入群
  738. // $members = $input["NewMemberList"];
  739. // if($members) foreach($members as $k => $v) {
  740. // RedisUtil::getInstance('online',$input["GroupId"])->hSet($v["Member_Account"],$v["Member_Account"]);
  741. // // 更新房间在线状态
  742. // $party_id = $input["GroupId"];
  743. // $partyInfo = $redis->get("party_".$party_id);
  744. // if($partyInfo) {
  745. // $partyInfo = json_decode($partyInfo,true);
  746. // if($partyInfo["is_online"] != 1) {
  747. // $partyInfo["is_online"] = 1;
  748. // $redis->set("party_".$party_id,json_encode($partyInfo));
  749. // \app\common\model\Party::update(["is_online"=>1],["id"=>$party_id]);
  750. // }
  751. // }
  752. // }
  753. // $res = [];
  754. // $res["ActionStatus"] = "OK";
  755. // $res["ErrorCode"] = 0;
  756. // $res["ErrorInfo"] = "";
  757. // echo json_encode($res);
  758. // break;
  759. // case 'Group.CallbackAfterMemberExit': // 成员离开
  760. // $members = $input["ExitMemberList"];
  761. // if($members) foreach($members as $k => $v) {
  762. // RedisUtil::getInstance('online',$input["GroupId"])->HDel($v["Member_Account"]);
  763. // }
  764. // // 更新房间在线状态
  765. // $party_id = $input["GroupId"];
  766. // $partyInfo = RedisUtil::getInstance('party',$party_id)->get();
  767. // if($partyInfo) {
  768. // $partyInfo = json_decode($partyInfo,true);
  769. // $memCount = count(RedisUtil::getInstance('online',$party_id)->hGetAll());
  770. // if($memCount <= 0) {
  771. // $partyInfo["is_online"] = 0;
  772. // RedisUtil::getInstance('party',$party_id)->set(json_encode($partyInfo));
  773. // \app\common\model\Party::update(["is_online"=>0],["id"=>$party_id]);
  774. // }
  775. // }
  776. //
  777. // $liveInfo = RedisUtil::getInstance('live',$party_id)->get();
  778. // if($liveInfo) {
  779. // $liveInfo = json_decode($liveInfo,true);
  780. // $memCount = count(RedisUtil::getInstance('online',$party_id)->hGetAll());
  781. // if($memCount <= 0) {
  782. // $liveInfo["is_online"] = 0;
  783. // RedisUtil::getInstance('live',$party_id)->set(json_encode($liveInfo));
  784. // \app\common\model\Party::update(["is_online"=>0],["id"=>$party_id]);
  785. // }
  786. // }
  787. //
  788. // $res = [];
  789. // $res["ActionStatus"] = "OK";
  790. // $res["ErrorCode"] = 0;
  791. // $res["ErrorInfo"] = "";
  792. // echo json_encode($res);
  793. // break;
  794. /*case 'Group.CallbackBeforeSendMsg': // 群内发送消息之前
  795. $config = config("wxMiniProgram");
  796. $access_token_url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$config["appid"]."&secret=".$config["secret"];
  797. $access_token_arr = $this->getJson($access_token_url);
  798. $access_token = isset($access_token_arr["access_token"])?$access_token_arr["access_token"]:"";
  799. if(!$access_token) {
  800. $res = [];
  801. $res["ActionStatus"] = "OK";
  802. $res["ErrorInfo"] = "";
  803. $res["ErrorCode"] = 0;
  804. echo json_encode($res);
  805. break;
  806. }
  807. // \app\common\model\Test::update(["content"=>json_encode($access_token)],["id"=>1]);
  808. $infoMessage = $input["MsgBody"];
  809. $badMessage = false;
  810. if($infoMessage) foreach($infoMessage as $k => $v) {
  811. if(isset($v["MsgContent"]["Text"])) {
  812. $message = json_decode($v["MsgContent"]["Text"],true);
  813. $content = isset($message["content"])?$message["content"]:"";
  814. $message_check_url ='https://api.weixin.qq.com/wxa/msg_sec_check?access_token='.$access_token;
  815. $tencentObj = new tencentim($message_check_url);
  816. $content_json = '{"content": "'.$content.'"}';
  817. $body = $tencentObj->messageCheck($content_json);
  818. if($body["errcode"] == 87014) {
  819. // \app\common\model\Test::update(["content"=>$body["errcode"]],["id"=>1]);
  820. // $res = [];
  821. // $res["ActionStatus"] = "OK";
  822. // $res["ErrorInfo"] = "检测到敏感词汇!";
  823. // $res["ErrorCode"] = 1;
  824. // echo json_encode($res);exit;
  825. $message["content"] = "*******";
  826. $infoMessage[$k]["MsgContent"]["Text"] = json_encode($message);
  827. $badMessage = true;
  828. }
  829. }
  830. }
  831. if($badMessage) {
  832. $res = [];
  833. $res["ActionStatus"] = "OK";
  834. $res["ErrorInfo"] = "检测到敏感词汇!";
  835. $res["ErrorCode"] = 10102;
  836. $res["MsgBody"] = $infoMessage;
  837. } else {
  838. $res = [];
  839. $res["ActionStatus"] = "OK";
  840. $res["ErrorInfo"] = "";
  841. $res["ErrorCode"] = 0;
  842. }
  843. // \app\common\model\Test::update(["content"=>json_encode($res)],["id"=>1]);
  844. echo json_encode($res);exit;
  845. break;*/
  846. default:
  847. break;
  848. }
  849. exit;
  850. }
  851. private function getJson($url){
  852. $ch = curl_init();
  853. curl_setopt($ch, CURLOPT_URL, $url);
  854. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  855. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
  856. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  857. $output = curl_exec($ch);
  858. curl_close($ch);
  859. return json_decode($output, true);
  860. }
  861. /**
  862. * 发送消息给某人
  863. * type:0普通消息 1自定义消息
  864. */
  865. public function sendMessageToUser($from_user,$to_user,$message, $type = 0) {
  866. $from_user = $this->prefix . (string)$from_user;
  867. $to_user = $this->prefix . (string)$to_user;
  868. // $message = "sdsd";
  869. $random = rand(10000000,99999999);
  870. $usersig = $this->usersig("administrator");
  871. // 获取配置信息
  872. $config = config("tencent_im");
  873. $url = "https://console.tim.qq.com/v4/openim/sendmsg";
  874. $url .= "?sdkappid=".$config["sdkappid"];
  875. $url .= "&identifier=administrator";
  876. $url .= "&usersig=".$usersig;
  877. $url .= "&random=".$random;
  878. $url .= "&contenttype=json";
  879. $tencentObj = new tencentim($url);
  880. $data = [];
  881. $data["SyncOtherMachine"] = 1;
  882. $data["From_Account"] = $from_user;
  883. $data["To_Account"] = $to_user;
  884. $data["MsgRandom"] = rand(1000000,9999999);
  885. $data["MsgTimeStamp"] = time();
  886. if ($type == 1) { //自定义消息
  887. $body_message = '{"businessID":"custom_tips_message","receiverShow":true,"senderId":"'.$from_user.'","text":"'.$message.'","tipType":"257","version":0}';
  888. $data["MsgBody"][] = [
  889. "MsgType" => "TIMCustomElem",
  890. "MsgContent" => [
  891. "Data" => $body_message,
  892. "Desc" => $body_message,
  893. "Ext" => 'custom_tips_message',
  894. "Sound" => ''
  895. ],
  896. ];
  897. } else {
  898. $data["MsgBody"][] = [
  899. "MsgType" => "TIMTextElem",
  900. "MsgContent" => [
  901. "Text" => $message
  902. ],
  903. ];
  904. }
  905. $rs = $tencentObj->toSend($data);//p($rs);
  906. }
  907. /**
  908. * 发送消息给某人-接口调用
  909. */
  910. public function sendToUser() {
  911. $from_user = $this->request->request("from_user");// 发送者
  912. $to_user = $this->request->request("to_user");// 接收者
  913. $message = $this->request->request("message");// 接收者
  914. if(!$from_user || !$to_user || !$message) $this->error("参数缺失!");
  915. $this->sendMessageToUser($from_user,$to_user,$message, 1);
  916. }
  917. //请求的基础参数
  918. private function baseTencentObj($url)
  919. {
  920. $random = rand(10000000,99999999);
  921. $usersig = $this->usersig("administrator");
  922. // 获取配置信息
  923. $config = config("tencent_im");
  924. $url = "$url";
  925. $url .= "?sdkappid=".$config["sdkappid"];
  926. $url .= "&identifier=administrator";
  927. $url .= "&usersig=".$usersig;
  928. $url .= "&random=".$random;
  929. $url .= "&contenttype=json";
  930. return new tencentim($url);
  931. }
  932. /** 设置管理员(im端的改变)
  933. * @param $user_id
  934. * @param $party_id
  935. * @param int $status 1:yes 0:no
  936. * @return array|false|mixed
  937. */
  938. public function setUpIMAdmin($user_id, $party_id, int $status=0) {
  939. $url = "https://console.tim.qq.com/v4/group_open_http_svc/modify_group_member_info";
  940. $tencentObj = $this->baseTencentObj($url);
  941. $groupInfo = $this->getGroupInfo($party_id);
  942. if($groupInfo["GroupInfo"][0]["ErrorCode"] > 0) return false;
  943. // 更新的信息
  944. $data = [];
  945. $data["GroupId"] = $party_id;
  946. if ($status==1){
  947. $data['Role'] = 'Admin';
  948. }else{
  949. $data['Role'] = 'Member';
  950. }
  951. $data['Member_Account'] = $user_id;
  952. return $tencentObj->toSend($data);
  953. }
  954. //获取群成员详细资料(目前没用到)
  955. private function getGroupMemberDetails($party_id)
  956. {
  957. $url = "https://console.tim.qq.com/v4/group_open_http_svc/get_group_member_info";
  958. $tencentObj = $this->baseTencentObj($url);
  959. // 获取群组信息
  960. $groupInfo = $this->getGroupInfo($party_id);
  961. if($groupInfo["GroupInfo"][0]["ErrorCode"] > 0) return false;
  962. // 更新的信息
  963. $data = [];
  964. $data["GroupId"] = $party_id;
  965. return $tencentObj->toSend($data);
  966. }
  967. //IM管理员维护,同步本地管理员
  968. public function imAdminMaintenance()
  969. {
  970. $partyIds = \app\admin\model\party\Party::column('id');
  971. foreach ($partyIds as $party_id){
  972. $groupInfo = $this->getGroupInfo($party_id);
  973. if($groupInfo["GroupInfo"][0]["ErrorCode"] > 0) continue;
  974. $roomInfoData = $groupInfo["GroupInfo"][0]["AppDefinedData"];
  975. $roomInfo = [];
  976. if($roomInfoData) foreach($roomInfoData as $k => $v) {
  977. if($v["Key"] == "roomInfo") $roomInfo = $v["Value"];
  978. }
  979. $roomInfo = json_decode($roomInfo,true);
  980. // 更新管理员
  981. if(isset($roomInfo["managers"]) && !empty($roomInfo['managers'])) {
  982. foreach ($roomInfo['managers'] as $v){
  983. $this->setUpIMAdmin($v,$party_id,1);
  984. }
  985. }
  986. }
  987. $this->success("成功!");
  988. }
  989. //拉黑
  990. public function black_one($from_user = '',$to_user = '') {
  991. $from_user = $this->prefix . (string)$from_user;
  992. $to_user = $this->prefix . (string)$to_user;
  993. $random = rand(10000000,99999999);
  994. $usersig = $this->usersig("administrator");
  995. // 获取配置信息
  996. $config = config("tencent_im");
  997. $url = "https://console.tim.qq.com/v4/sns/black_list_add";
  998. $url .= "?sdkappid=".$config["sdkappid"];
  999. $url .= "&identifier=administrator";
  1000. $url .= "&usersig=".$usersig;
  1001. $url .= "&random=".$random;
  1002. $url .= "&contenttype=json";
  1003. $tencentObj = new tencentim($url);
  1004. $data = [];
  1005. $data["From_Account"] = $from_user;
  1006. $data["To_Account"] = [$to_user];
  1007. $rs = $tencentObj->toSend($data);
  1008. return $rs;
  1009. }
  1010. //取消拉黑
  1011. public function un_black_one($from_user = '',$to_user = '') {
  1012. $from_user = $this->prefix . (string)$from_user;
  1013. $to_user = $this->prefix . (string)$to_user;
  1014. $random = rand(10000000,99999999);
  1015. $usersig = $this->usersig("administrator");
  1016. // 获取配置信息
  1017. $config = config("tencent_im");
  1018. $url = "https://console.tim.qq.com/v4/sns/black_list_delete";
  1019. $url .= "?sdkappid=".$config["sdkappid"];
  1020. $url .= "&identifier=administrator";
  1021. $url .= "&usersig=".$usersig;
  1022. $url .= "&random=".$random;
  1023. $url .= "&contenttype=json";
  1024. $tencentObj = new tencentim($url);
  1025. $data = [];
  1026. $data["From_Account"] = $from_user;
  1027. $data["To_Account"] = [$to_user];
  1028. $rs = $tencentObj->toSend($data);
  1029. return $rs;
  1030. }
  1031. //撤回单聊消息
  1032. public function withdraw_message($from_user = '', $to_user = '',$msgkey = '') {
  1033. // $from_user = 54;
  1034. // $to_user = 6;
  1035. // $message = "sdsd";
  1036. $random = rand(10000000,99999999);
  1037. $usersig = $this->usersig("administrator");
  1038. // 获取配置信息
  1039. $config = config("tencent_im");
  1040. $url = "https://console.tim.qq.com/v4/openim/admin_msgwithdraw";
  1041. $url .= "?sdkappid=".$config["sdkappid"];
  1042. $url .= "&identifier=administrator";
  1043. $url .= "&usersig=".$usersig;
  1044. $url .= "&random=".$random;
  1045. $url .= "&contenttype=json";
  1046. $tencentObj = new tencentim($url);
  1047. $data = [];
  1048. $data["From_Account"] = (string)$from_user;
  1049. $data["To_Account"] = (string)$to_user;
  1050. $data["MsgKey"] = (string)$msgkey;
  1051. $rs = $tencentObj->toSend($data);//p($rs);
  1052. return $rs;
  1053. }
  1054. }