【PHP】创蓝253云通信平台国际短信接口调用demo案例
PHP接口请求类
<?php
header("Content-type:text/html; charset=UTF-8");
/
- 类名:ChuanglanSmsApi
- 功能:创蓝接口请求类
- 详细:构造创蓝短信接口请求,获取远程HTTP数据
- 版本:1.3
- 日期:2017-04-12
- 说明:
- 以下代码只是为了方便客户测试而提供的样例代码,客户可以根据自己网站的需要,按照技术文档自行编写,并非一
定要使用该代码。 - 该代码仅供学习和研究创蓝接口使用,只是提供一个参考。
*/
class ChuanglanSmsApi {
//Interface URL Used to send SMS
const API_SEND_URL='http://intapi.253.com/send/json?';//Interface URL Used to Query SMS balance
const API_BALANCE_QUERY_URL='http://intapi.253.com/balance/json?';const API_ACCOUNT='';//Get SMS Account from https://zz.253.com/site/login.html const API_PASSWORD='';//Get SMS Password from https://zz.253.com/site/login.html/*** 发送短信** @param string $mobile 手机号码* @param string $msg 短信内容*/
public function sendInternational( $mobile, $msg) {//创蓝接口参数$postArr = array ('account' => self::API_ACCOUNT,'password' => self::API_PASSWORD,'msg' => $msg,'mobile' => $mobile);$result = $this->curlPost( self::API_SEND_URL , $postArr);return $result;
}/*** 查询额度** 查询地址*/
public function queryBalance() {//查询参数$postArr = array ( 'account' => self::API_ACCOUNT,'password' => self::API_PASSWORD,);$result = $this->curlPost(self::API_BALANCE_QUERY_URL, $postArr);return $result;
}/*** 通过CURL发送HTTP请求* @param string $url //请求URL* @param array $postFields //请求参数 * @return mixed*/
private function curlPost($url,$postFields){$postFields = json_encode($postFields);$ch = curl_init ();curl_setopt( $ch, CURLOPT_URL, $url ); curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8'));curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );curl_setopt( $ch, CURLOPT_POST, 1 );curl_setopt( $ch, CURLOPT_POSTFIELDS, $postFields);curl_setopt( $ch, CURLOPT_TIMEOUT,1); curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0);curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0);$ret = curl_exec ( $ch );if (false == $ret) {$result = curl_error( $ch);} else {$rsp = curl_getinfo( $ch, CURLINFO_HTTP_CODE);if (200 !== $rsp) {$result = "请求状态 ". $rsp . " " . curl_error($ch);} else {$result = $ret;}}curl_close ( $ch );return $result;
}
}
转载于:https://blog.51cto.com/13750674/2141664
【PHP】创蓝253云通信平台国际短信接口调用demo案例相关推荐
- 【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 ...
- 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 ...
- 【Shell】创蓝253云通讯平台国际短信API接口DEMO
#!/bin/sh # account and password can be change to what you wanna! #author ChuangLan #修改为您的account ac ...
- php创蓝253四要素认证_PHP短信接口分享:适用于创蓝253平台下的短信验证码、短信服务接口...
header("Content-type:text/html; charset=UTF-8"); class ChuanglanSmsApi { //发送短信的接口地址 const ...
- 短信验证码、短信服务商接口---PHP---对接创蓝253云通讯平台
<?php header("Content-type:text/html; charset=UTF-8"); class ChuanglanSmsApi { //发送短信的接 ...
- 创蓝253云通讯短信平台变量说明
创蓝253云通讯变量说明文档 变量短信发送 用户通过HTTP的POST方式提交短信发送请求. 系统提交URL地址 http://sms.253.com/msg/HttpVarSM 参数定义 序号 参数 ...
- Python---短信接口demo,对接创蓝253云通讯paas平台
#!/usr/local/bin/python #-*- coding:utf-8 -*- # Author: jacky # Time: 14-2-22 下午11:48 # Desc: 短信http ...
最新文章
- vue通过class获取dom_.NET Core通过Json或直接获取图形验证码(务必收藏备用)
- jzoj3794,P1383-高级打字机【欧拉序,离线O(n)】
- 多线程程序中操作的原子性
- 二十七、PHP框架Laravel学习笔记——模型的多对多关联
- Spring 官宣,干掉原生 JVM!
- (Mark)JS中的上下文
- 【2010】asp.net GridView分页的实现
- using c++11 standerd in qt
- 工业4.0围观,大炒作,大问题,大差距,你发现了吗?
- eclipse代码编辑区字符串自动转义设置
- 二分查找时间复杂度分析
- Windows中MySQL主从数据库搭建(二)
- 查看sql语句的执行计划
- 新人主播开播以后,碰到的各类问题和解决方法
- 《缠中说禅108课》37:背驰的再分辨
- Ubuntu16.04 系统托盘topbar隐藏albert图标
- 大数据营销在电商领域的应用案例
- tc ebpf 实践
- 高并发编程之ThreadPool 线程池
- 记录某学校热水卡安全性研究