webserive接口调用

public function test()
{

libxml_disable_entity_loader(false);
ini_set("soap.wsdl_cache_enabled", "0");



$soap = new \SoapClient ('http://172.24.64.65:8080/ghsms/services/SMS?WSDL');


$scode = rand(1000,9999);
$ncode = $scode;
$id = "UE35".time().$ncode."0";
$post_xml ='<?xml version="1.0" encoding="utf-8"?><SMS type="send">
<Message SmsID="UE35151452798612320" Bid="CMS" RecvNum="18510344423" Content="验证码为502637,有效期为五分钟。"/></SMS>';

try{
$b= $soap->__soapCall('AddSMSList',array("parameters"=>array("in0"=>"POWERU-SMS","in1"=>$post_xml)));    //参考wsdl文件参数说明

dump($b);

// print_r($soapaaa->__getFunctions());

}catch(SoapFault $e){
echo $e->getMessage() .$e->getCode() .PHP_EOL;
}
}

插件的话,试过nusoap插件,也挺简单的。

import("Vendor.nusoap.nusoap",'','.php');
$phone = I('param.phone');//用户手机号

if (!$phone || !preg_match("/^1[0-9]{1}[0-9]{1}[0-9]{8}$|15[0189]{1}[0-9]{8}$|189[0-9]{8}$/", $phone)) {
$ret = array('succeed' => '0', 'message' => '手机号不正确');
$this->ouputMessage->outputMessage($ret);
return;
}
$smscode = rand(1000, 9999);
$nowcode = $smscode;
$scode = rand(1000,9999);
$ncode = $scode;
$time = date("YmdHis");
$timeend = date("YmdHis", time() + 180);
$id = "UE35".time().$ncode."0";
$post_xml ='<?xml version="1.0" encoding="utf-8"?><SMS type="send"><Message SmsID="'.$id.'" Bid="CMS" RecvNum="'.$phone.'" Content="验证码为'.$nowcode.'"/></SMS>';
$url = "  ";  //地址
$client = new \nusoap_client($url,true);
$client->soap_defencoding = 'UTF-8';
$client->decode_utf8 = false;
$client->xml_encoding = 'UTF-8';
$res = $client->call('AddSMSList',array("in0"=>"POWERU-SMS","in1"=>$post_xml));

if ($res['out'] == "success") {
$ret = array('succeed' => '1', 'message' => '短信发送成功,2分钟有效期');
$key = "User_smsauth_" . $phone;
if ($this->redis->set($key, json_encode(array("smscode" => $smscode, "time" => time())), 120)) {

} else {
$ret = array('succeed' => '0', 'message' => '短信发送失败');

}
} else {
$ret = array('succeed' => '0', 'message' => '短信发送失败');

return;
}

转载于:https://www.cnblogs.com/xiaoyueya/p/8178089.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值