本文主要是介绍PHP实现赛邮【SUBMAIL】短信通知,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
接口文档地址:https://www.mysubmail.com/documents
实现短信通知实例:
$url = 'https://api-v4.mysubmail.com/sms/xsend';//接口地址
$appId = 'XXX';//APPID
$appkey = 'XXX';//APPKEY
$phone = 'XXX';//发送手机号
$project = 'XXX';//模板ID
$data = ['appid' => $appId,'to' => $phone,'timestamp' => time(),'sign_type' => 'md5','sign_version' => 2,'project' => $project
];
ksort($data);
$signature = $appId . $appkey . http_build_query($data) . $appId . $appkey;
$data['signature'] = md5($signature);//数字签名
$vars = ['code' => 'XXX',
];
$data['vars'] = json_encode($vars);//文本变量$client = new Client();
$response = $client->createRequest()->setMethod('POST')->setUrl($url)->setData($data)->setHeaders(['Content-Type'=>'application/json',])->setFormat(Client::FORMAT_JSON) //提交的数据的格式->send();
如上可以实现给指定手机号发送指定模板的通知内容,其他方式可参照文档实现
这篇关于PHP实现赛邮【SUBMAIL】短信通知的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!