短信验证码、短信服务商接口---PHP---对接创蓝253云通讯平台
<?php
header("Content-type:text/html; charset=UTF-8");
class ChuanglanSmsApi {
//发送短信的接口地址
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 里面获取。
/**
* 发送短信需要的接口参数
*
* @param string $mobile 手机号码
* @param string $msg 想要发送的短信内容
* @param string $needstatus 是否需要状态报告 '1'为需要 '0'位不需要。
*/
public function sendSMS( $mobile, $msg, $needstatus= 1) {
//发送短信的接口参数
$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() {
// 查询接口参数
$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;
}
//魔术获取
public function __get($name){
return $this->$name;
}
//魔术设置
public function __set($name,$value){
$this->$name=$value;
}
}
?>
如有缺漏,欢迎补充
短信验证码、短信服务商接口---PHP---对接创蓝253云通讯平台相关推荐
- Python---短信接口demo,对接创蓝253云通讯paas平台
#!/usr/local/bin/python #-*- coding:utf-8 -*- # Author: jacky # Time: 14-2-22 下午11:48 # Desc: 短信http ...
- 【Python】创蓝253云通讯平台---国际短信API接口demo
#!/usr/local/bin/python #-*- coding:utf-8 -*- # Author: jacky # Time: 14-2-22 下午11:48 # Desc: 短信http ...
- 【Python】创蓝253云通讯平台国际短信API接口DEMO
#!/usr/local/bin/python #-*- coding:utf-8 -*- # Author: jacky # Time: 14-2-22 下午11:48 # Desc: 短信http ...
- 【Shell】创蓝253云通讯平台国际短信API接口DEMO
#!/bin/sh # account and password can be change to what you wanna! #author ChuangLan #修改为您的account ac ...
- php创蓝253四要素认证_【PHP】创蓝253云通讯平台国际短信API接口demo
PHP接口请求类 header("Content-type:text/html; charset=UTF-8"); /* * * 类名:ChuanglanSmsApi * 功能:创 ...
- 【PHP】创蓝253云通讯平台国际短信API接口demo
PHP接口请求类 <?php header("Content-type:text/html; charset=UTF-8"); /* * * 类名:ChuanglanSmsA ...
- 创蓝253云通讯 paas 短信发送接口和定义说明
一.demo: #include <arpa/inet.h> #include <assert.h> #include <errno.h> #include < ...
- 创蓝253云通讯短信平台变量说明
创蓝253云通讯变量说明文档 变量短信发送 用户通过HTTP的POST方式提交短信发送请求. 系统提交URL地址 http://sms.253.com/msg/HttpVarSM 参数定义 序号 参数 ...
- python设计查询余额程序_【Python】短信验证码平台查询账户余额demo---创蓝253云通讯平台案例...
#!/usr/local/bin/python #- - coding:utf-8 -- Author: jacky Time: 14-2-22 下午11:48 Desc: 短信http接口的pyth ...
最新文章
- 软件的一切关乎成本,以消亡为结束
- HTTPS Web配置举例
- 图解Win7下安装Oracle 12c
- 1050 循环数组最大子段和
- 老蒋的 用WDCP 搭建
- 基于Tensorflow实现多层感知机网络MLPs
- oracle协议适配器错误tns,ORA-12560: TNS: 协议适配器错误 常见原因
- redis系列之1----redis简介以及linux上的安装
- 入职与离职手续、五险一金、档案
- vue安装(linux)
- python selenium模拟浏览器操作实战(武汉大学原教务系统)
- 【飞飞CMS二次开发实录】开篇:安装与运行
- Android开发丶openinstall的集成和使用(推广二维码)
- person reid demo郑哲东 Deep ReID
- android app 仿小米全面屏手势返回UI样式
- 互联网卷王花落谁家?
- CocosCreator Effect (Shader) - 斜条纹如何画
- 不是所有码农都有货之Java 实例 - 数组并集
- 你的简历真的做的好吗?一起来看看软件测试简历的常见误区
- 快速启动nacos脚本