微信掃一掃
認(rèn)證、簽名模板審核結(jié)果通知
賬號(hào)短信余額不足提醒
平臺(tái)促銷活動(dòng)及最新資訊
秒賽為開發(fā)者提供了詳細(xì)的API文檔和代碼示例,幫助開發(fā)者快速接入短信平臺(tái)
<?php
class
SendCode{
private
$url
=
'http://139.196.108.241:8080'
;
private
function
post_curls(
$url
,
$post
)
{
$curl
= curl_init();
// 啟動(dòng)一個(gè)CURL會(huì)話
curl_setopt(
$curl
, CURLOPT_URL,
$url
);
// 要訪問的地址
curl_setopt(
$curl
, CURLOPT_SSL_VERIFYPEER, 0);
// 對(duì)認(rèn)證證書來源的檢查
curl_setopt(
$curl
, CURLOPT_USERAGENT,
$_SERVER
[
'HTTP_USER_AGENT'
]);
// 模擬用戶使用的瀏覽器
curl_setopt(
$curl
, CURLOPT_FOLLOWLOCATION, 1);
// 使用自動(dòng)跳轉(zhuǎn)
curl_setopt(
$curl
, CURLOPT_AUTOREFERER, 1);
// 自動(dòng)設(shè)置Referer
curl_setopt(
$curl
, CURLOPT_POST, 1);
// 發(fā)送一個(gè)常規(guī)的Post請(qǐng)求
curl_setopt(
$curl
, CURLOPT_POSTFIELDS,
$post
);
// Post提交的數(shù)據(jù)包
curl_setopt(
$curl
, CURLOPT_TIMEOUT, 30);
// 設(shè)置超時(shí)限制防止死循環(huán)
curl_setopt(
$curl
, CURLOPT_HEADER, 0);
// 顯示返回的Header區(qū)域內(nèi)容
curl_setopt(
$curl
, CURLOPT_RETURNTRANSFER, 1);
// 獲取的信息以文件流的形式返回
$res
= curl_exec(
$curl
);
// 執(zhí)行操作
if
(curl_errno(
$curl
)) {
echo
'Errno'
.curl_error(
$curl
);
//捕抓異常
}
curl_close(
$curl
);
// 關(guān)閉CURL會(huì)話
return
$res
;
// 返回?cái)?shù)據(jù),json格式
}
//$account 用戶賬號(hào)
//$pswd 必填參數(shù)。用戶密碼
//$mobile 必填參數(shù)。合法的手機(jī)號(hào)碼
//$msg 必填參數(shù)。短信內(nèi)容
//$ts 可選參數(shù),時(shí)間戳,格式y(tǒng)yyyMMddHHmmss
//$state 必填參數(shù) 狀態(tài) 1:驗(yàn)證碼短信 2:營(yíng)銷短信 3:語音驗(yàn)證碼
public
function
send(
$account
,
$pswd
,
$mobile
,
$msg
,
$ts
,
$state
){
if
(
$ts
!=
''
){
$pswd
= md5(
$account
.
$pswd
.
$ts
);
}
$url
=
''
;
switch
(
$state
) {
case
1:
$url
=
$this
->url.
'/Api/HttpSendSMYzm.ashx'
;
break
;
case
2:
$url
=
$this
->url.
'/Api/HttpSendSMYx.ashx'
;
break
;
case
3:
$url
=
$this
->url.
'/Api/HttpSendSMVoice.ashx'
;
break
;
default
:
$url
=
''
;
break
;
}
$data
=
array
(
'account'
=>
$account
,
'pswd'
=>
$pswd
,
'mobile'
=>
$mobile
,
'msg'
=>
$msg
,
'ts'
=>
$ts
);
$huawei_res
=
$this
->post_curls(
$url
,
$data
);
$huawei_res
=json_decode(
$huawei_res
,true);
return
$huawei_res
;
}
}
//$account 用戶賬號(hào)
//$pswd 必填參數(shù)。用戶密碼
//$mobile 必填參數(shù)。合法的手機(jī)號(hào)碼
//$msg 必填參數(shù)。短信內(nèi)容
//$ts 可選參數(shù),時(shí)間戳,格式y(tǒng)yyyMMddHHmmss
//$state 必填參數(shù) 狀態(tài) 1:驗(yàn)證碼短信 2:營(yíng)銷短信 3:語音驗(yàn)證碼
$send
=
new
SendCode();
$re
=
$send
->send(
'您的賬號(hào)'
,
'您的密碼'
,
'手機(jī)號(hào)'
,
'短信內(nèi)容'
,time(),1);
print_r(
$re
);
認(rèn)證、簽名模板審核結(jié)果通知
賬號(hào)短信余額不足提醒
平臺(tái)促銷活動(dòng)及最新資訊