文档概览

PHP

短信接口
class ChuanglanSMS{
	const SENDURL='http://IP:端口';
	const QUERYURL='http://IP:端口';
	const ISENDURL='http://IP:端口';
	const IQUERYURL='http://IP:端口';

	private $_sendUrl='';		 
	private $_queryBalanceUrl='';	// 查询余额接口url

	private $_un;			// 账号
	private $_pw;			// 密码

	
	public function __construct($account,$password){
		$this--->_un=$account;
		$this->_pw=$password;
	}

	
	public function send($phone,$content,$isreport=0){
		$requestData=array(
			'un'=>$this->_un,
			'pw'=>$this->_pw,
			'sm'=>$content,
			'da'=>$phone,
			'rd'=>$isreport,
			'dc'=>15,
			'rf'=>2,
			'tf'=>3,
		);
		
		$url=ChuanglanSMS::SENDURL.'?'.http_build_query($requestData);
		return $this->_request($url);
	}

	
	public function sendInternational($phone,$content,$isreport=0){
		$requestData=array(
			'un'=>$this->_un,
			'pw'=>$this->_pw,
			'sm'=>$content,
			'da'=>$phone,
			'rd'=>$isreport,
			'rf'=>2,
			'tf'=>3,
		);
		
		$url=ChuanglanSMS::ISENDURL.'?'.http_build_query($requestData);
		return $this->_request($url);
	}


	 * 查询余额
	
	public function queryBalance(){
		$requestData=array(
			'un'=>$this->_un,
			'pw'=>$this->_pw,
			'rf'=>2
		);

		$url=ChuanglanSMS::QUERYURL.'?'.http_build_query($requestData);
		return $this->_request($url);
	}


	 * 查询余额
	 * @return String 余额返回

	public function queryBalanceInternational(){
		$requestData=array(
			'un'=>$this->_un,
			'pw'=>$this->_pw,
			'rf'=>2
		);

		$url=ChuanglanSMS::IQUERYURL.'?'.http_build_query($requestData);
		return $this->_request($url);
	}

	
	 * 请求发送
	 * @return string 返回状态报告
	
	private function _request($url){
		$ch=curl_init();
		curl_setopt($ch,CURLOPT_HEADER,0);
		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
		curl_setopt($ch,CURLOPT_URL,$url);
		$result=curl_exec($ch);
		curl_close($ch);
		return $result;
	}

}
 
QQ在线咨询
服务热线
021-31652084
24小时电话
15900894283