常见问题 — 详情

php短信验证码接口代码示例(简单、易用)

2017/12/1 10:43:49

今天给大家分享的代码示例是秒赛短信验证码平台为方便用户接入网站/app/各种系统,提供的PHP短信接口请求的代码示例,供大家参考。


php短信接口

php短信接口


PHP短信接口代码具体内容如下:


<?php
header("Content-Type:text/html;charset=utf-8");

//账号
$account = "***************"; 

//密码
$pswd = "***************"; 

//修改为您要发送的手机号
$mobile = "***************"; 

//发送地址,请咨询客服
$url = "***************"; 

//是否需要状态报告,为true即可
$needstatus = "true"; 

//产品,为空即可
$product = ""; 

$ch = curl_init();

/* 设置验证方式 */
curl_setopt($ch, CURLOPT_HTTPHEADER, 
array('Accept:text/plain;charset=utf-8', 'Content-Type:application/x-www-form-urlencoded','charset=utf-8'));

/* 设置返回结果为流 */
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

/* 设置超时时间*/
curl_setopt($ch, CURLOPT_TIMEOUT, 10);

/* 设置通信方式 */
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);


// 发送短信
$msg="【秒赛科技】您的验证码是:1234";  
$data=array('msg'=>$msg,'account'=>$account,'pswd'=>$pswd,'mobile'=>
$mobile,'needstatus'=>$needstatus,'product'=>$product);
$result = send($ch,$data);
echo '<pre>';print_r($result);

curl_close($ch);

/***************************************************************************************/


//验证码
function send($ch,$data){
    curl_setopt ($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
    return curl_exec($ch);
}


?>


想查看更多语言(java、c++、js)短信接口示例,点击:http://www.shmiaosai.com/support/show-79.html

4步接入,快速触达您的客户

全程在线客服24小时服务

  • 注册账号
  • 身份认证
  • 签名&报备
  • 充值使用