腾讯通消息webSDK踩坑

 

1.腾讯通提供一个通过http协议的接口,可用于发送消息,公告等功能,要使用其功能首先要开启RTX_HTTPServer服务。

2.阅读文档http://rtx.tencent.com/sdk/,为了发送消息需要调用sendim.cgi接口

3.实际上sendim.cgi内容如下:

  参数receiver应该为receivers,另外也应该以;为间隔

  参数sessionid格式应该为{45E974F3-B242-486b-8487-56C23D37F152},用来标记窗口会话

<?PHP

require_once "IPLimit.php";


$pwd = "";

$sender = $_GET["sender"];
$pwd = $_GET["pwd"];
$receivers = $_GET["receivers"];
$msg = $_GET["msg"];
$sessionid = $_GET["sessionid"];


if ((strlen($sender) == 0) 
	&& (strlen($pwd) == 0) 
	&& (strlen($receiver) == 0) 
	&& (strlen($msg) == 0) 
	&& (strlen($sessionid) == 0))
{
	$sender = $_POST["sender"];
	$pwd = $_POST["pwd"];
	$receivers = $_POST["receivers"];
	$msg = $_POST["msg"];
	$sessionid = $_POST["sessionid"];

}


try
{

	$RootObj= new COM("RTXSAPIRootObj.RTXSAPIRootObj");
	$RootObj->SendIM($sender, $pwd, $receivers,$msg, $sessionid);

	echo "<script language=\"JavaScript\">\r\n";
	echo "alert(\"操作成功\")";
	echo "</script>\r\n";

}

catch (Exception $e) {

		//有任何其他异常,那么返回reg_err.php
		$errstr = $e->getMessage();
		echo $errstr;
	}

?>

 

posted @ 2017-08-08 16:54  半块西瓜皮  阅读(853)  评论(0编辑  收藏  举报