• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
小月牙
细心的积累生活中的点点滴滴,涓涓细流汇成大海。
博客园    首页    新随笔    联系   管理    订阅  订阅
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;
}

posted on 2018-01-02 17:15  小月牙  阅读(562)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3