日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

【PHP】创蓝253云通讯paas平台短信验证码接口调用emo

發(fā)布時間:2024/1/1 php 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【PHP】创蓝253云通讯paas平台短信验证码接口调用emo 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

?

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



class ChuanglanSmsApi {

? ? ? ? //
發(fā)送短信的接口地址
? ? ? ? const API_SEND_URL='http://sms.253.com/msg/send?';

? ? ? ? //
查詢余額的接口地址
? ? ? ? constAPI_BALANCE_QUERY_URL='http://sms.253.com/msg/balance?';

? ? ? ? const API_ACCOUNT='*******';//
短信賬號從?https://zz.253.com/site/login.html?里面獲取。

? ? ? ? const API_PASSWORD='*******';//
短信密碼從 from?https://zz.253.com/site/login.html?里面獲取。

? ? ? ? /**
? ? ? ???*
發(fā)送短信需要的接口參數(shù)
? ? ? ???*
? ? ? ???* @param string $mobile ? ?? ? ? ? ? ?
手機號碼
? ? ? ???* @param string $msg ? ?? ? ? ? ? ? ? ? ? ?
想要發(fā)送的短信內(nèi)容
? ? ? ???* @param string $needstatus ?? ? ?
是否需要狀態(tài)報告 '1'為需要 '0'位不需要。
? ? ? ???*/
? ? ? ? public function sendSMS( $mobile, $msg, $needstatus= 1) {
? ? ? ? ? ? ? ?
?
? ? ? ? ? ? ? ? //
發(fā)送短信的接口參數(shù)
? ? ? ? ? ? ? ? $postArr = array (
? ? ? ? ? ? ? ? ? ? ?? ? ? ? ?? ?? ?????'un' => self::API_ACCOUNT,
? ? ? ? ? ? ? ? ? ? ?? ? ? ? ?? ?? ?????'pw' => self::API_PASSWORD,
? ? ? ? ? ? ? ? ? ? ?? ? ? ? ?? ?? ?????'msg' => $msg,
? ? ? ? ? ? ? ? ? ? ?? ? ? ? ?? ?? ?????'phone' => $mobile,
? ? ? ? ? ? ? ? ? ? ?? ? ? ? ?? ?? ?????'rd' => $needstatus
? ?? ?? ?? ?? ???? ?);
? ? ? ? ? ? ? ?
?
? ? ? ? ? ? ? ? $result =$this->curlPost( self::API_SEND_URL , $postArr);
? ? ? ? ? ? ? ? return $result;
? ? ? ? }
? ? ? ?
?
? ? ? ? /**
? ? ? ???*
?
? ? ? ???*
? ? ? ???*??
查詢余額
? ? ? ???*/
? ? ? ? public function queryBalance() {
? ? ? ? ? ? ? ?
?
? ? ? ? ? ? ? ? //
查詢接口參數(shù)
? ? ? ? ? ? ? ? $postArr = array (
?
? ? ? ? ? ? ? ?? ???? ???'un' => self::API_ACCOUNT,
? ? ? ? ? ? ? ?? ???? ???'pw' => self::API_PASSWORD,
? ? ? ? ? ? ? ? );
? ? ? ? ? ? ? ? $result =$this->curlPost(self::API_BALANCE_QUERY_URL, $postArr);
? ? ? ? ? ? ? ? return $result;
? ? ? ? }

? ? ? ? /**
? ? ? ???*
處理接口返回值
? ? ? ???*
?
? ? ? ???*/
? ? ? ? public function execResult($result){
? ? ? ? ? ? ? ?$result=preg_split("/[,\r\n]/",$result);
? ? ? ? ? ? ? ? return $result;
? ? ? ? }

? ? ? ? /**
? ? ? ???* @param string $url??
? ? ? ???* @param array $postFields
?
? ? ? ???* @return mixed
? ? ? ???*/
? ? ? ? private function curlPost($url,$postFields){
? ? ? ? ? ? ? ? $postFields =http_build_query($postFields);
?
? ? ? ? ? ? ? ?if(function_exists('curl_init')){

? ? ? ? ? ? ? ? ? ? ?? $ch = curl_init ();
? ? ? ? ? ? ? ? ? ? ?? curl_setopt ( $ch, CURLOPT_POST, 1 );
? ? ? ? ? ? ? ? ? ? ?? curl_setopt ( $ch, CURLOPT_HEADER, 0 );
? ? ? ? ? ? ? ? ? ? ?? curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
? ? ? ? ? ? ? ? ? ? ?? curl_setopt ( $ch, CURLOPT_URL, $url );
? ? ? ? ? ? ? ? ? ? ?? curl_setopt ( $ch, CURLOPT_POSTFIELDS, $postFields );
? ? ? ? ? ? ? ? ? ? ?? $result = curl_exec ( $ch );
? ? ? ? ? ? ? ? ? ? ?? if(curl_errno($ch))
? ? ? ? ? ? ? ? ? ? ?? {
? ? ? ? ? ? ? ? ? ? ?? ? ? ? ? return 'Curl error: ' . curl_error($ch);
? ? ? ? ? ? ? ? ? ? ?? }
? ? ? ? ? ? ? ? ? ? ?? curl_close ( $ch );
? ? ? ? ? ? ? ?}elseif(function_exists('file_get_contents')){
? ? ? ? ? ? ? ? ? ? ??
?
? ? ? ? ? ? ? ? ? ? ?? $result=file_get_contents($url.$postFields);

? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? return $result;
? ? ? ? }
? ? ? ?
?
? ? ? ? //
魔術(shù)獲取
? ? ? ? public function __get($name){
? ? ? ? ? ? ? ? return $this->$name;
? ? ? ? }
? ? ? ?
?
? ? ? ? //
魔術(shù)設(shè)置
? ? ? ? public function __set($name,$value){
? ? ? ? ? ? ? ? $this->$name=$value;
? ? ? ? }
}
?>


總結(jié)

以上是生活随笔為你收集整理的【PHP】创蓝253云通讯paas平台短信验证码接口调用emo的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。