华信 PHP 调用短信接口示例

<?php

   header("Content-type: text/html; charset=utf-8");
    
    $account="";				//改为实际账户名
    $password="";				//改为实际短信发送密码
    $mobiles="";				//目标手机号码,多个用半角“,”分隔
    $extno = "";
    $content="【华信】您的验证码:8888";
    $sendtime = "";

    $result=MessageSend::send($account,$password,$mobiles,$extno,$content,$sendtime);
    
    $xml = simplexml_load_string($result);

    echo "返回信息提示::".$xml->message."<br>";
    echo "返回状态为:".$xml->returnstatus."<br>";
    echo "返回信息:".$xml->message."<br>";
    echo "返回余额:".$xml->remainpoint."<br>";
    echo "返回本次任务ID:".$xml->taskID."<br>";
    echo "返回成功短信数:".$xml->successCounts."<br>";


		//aspx接口调用
    class MessageSend
    {
    	const url ="https://dx.ipyy.net/sms.aspx";   //接口地址
    	static function send($account,$password,$mobiles,$extno,$content,$sendtime)
    	{
    		$body=array(
    				'action'=>'send',
    				'userid'=>'',
    				'account'=>$account,
    				'password'=>$password,
    				'mobile'=>$mobiles,
    				'extno'=>$extno,
    				'content'=>$content,
    				'sendtime'=>$sendtime    				
    		);
    		$ch=curl_init();
    		curl_setopt($ch, CURLOPT_URL, self::url);
    		curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
    		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
    		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,false);
    		curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    		$result = curl_exec($ch);
    		curl_close($ch);
    		return $result;
    	}
    }
?>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值