send_test.php

来自「为了对短消息信息应用开发商提供支持」· PHP 代码 · 共 36 行

PHP
36
字号
<?php
/*根据参数,生成调用URL,因为是测试例子,不对变量为空的情况做处理*/
$URL = "http://web.mobset.com/SDK/Sms_Send.asp?CorpID=".$_POST['CorpID']."&LoginName=".$_POST['LoginName']."&send_no=".$_POST['send_no']."&Timer=".$_POST['Timer']. "&msg=" .rawurlencode($_POST['msg']);

/*调用MSXML,发送请求*/
$objHttpRequest=new COM("MSXML2.ServerXMLHTTP");
if (is_null($objHttpRequest)) {
	echo "create Msxl2.ServerXMLHTTP error";
	exit();	
	}
	
$objHttpRequest->open("GET",$URL,False); 
$objHttpRequest->send();
if ($objHttpRequest->status <> 200) {
/*返回错误*/
	echo "open Request error";
	exit();
	}
	
/*取返回的信息,并分析*/
$retMsg=$objHttpRequest->responseText;
$Ret=strtok($retMsg,",");
$iRet=intval($Ret);

/*判断是否发送成功*/
if ($iRet>0) {
	$SendID=substr($retMsg,-(strlen($retMsg)-strlen($Ret)-1));
	echo "发送短信成功,SmsID:". $SendID;
	}
else {
    echo "发送短信失败,错误代码:" . $iRet;
}
	
/*释放对象*/
$objHttpRequest=NULL;
?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?