本文整理汇总了PHP中REST类的典型用法代码示例。如果您正苦于以下问题:PHP REST类的具体用法?PHP REST怎么用?PHP REST使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了REST类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: voiceVerify
/**
* 语音验证码
* @param verifyCode 验证码内容,为数字和英文字母,不区分大小写,长度4-8位
* @param playTimes 播放次数,1-3次
* @param to 接收号码
* @param displayNum 显示的主叫号码
* @param respUrl 语音验证码状态通知回调地址,云通讯平台将向该Url地址发送呼叫结果通知
* @param lang 语言类型。取值en(英文)、zh(中文),默认值zh。
* @param userData 第三方私有数据
* @param welcomePrompt 欢迎提示音,在播放验证码语音前播放此内容(语音文件格式为wav)
* @param playVerifyCode 语音验证码的内容全部播放此节点下的全部语音文件
*/
function voiceVerify($verifyCode, $playTimes, $to, $displayNum, $respUrl, $lang, $userData, $welcomePrompt, $playVerifyCode)
{
// 初始化REST SDK
$ci =& get_instance();
$sms = $ci->config->item('SMSCHANNEL');
$accountSid = $sms['accountSid'];
$accountToken = $sms['accountToken'];
$appId = $sms['appId'];
$serverIP = $sms['serverIP'];
$serverPort = $sms['serverPort'];
$softVersion = $sms['softVersion'];
// global $accountSid,$accountToken,$appId,$serverIP,$serverPort,$softVersion;
$rest = new REST($serverIP, $serverPort, $softVersion);
$rest->setAccount($accountSid, $accountToken);
$rest->setAppId($appId);
//调用语音验证码接口
$result = $rest->voiceVerify($verifyCode, $playTimes, $to, $displayNum, $respUrl, $lang, $userData, $welcomePrompt, $playVerifyCode);
if ($result->statusCode != 0) {
// echo "error code :" . $result->statusCode . "<br>";
// echo "error msg :" . $result->statusMsg . "<br>";
// //TODO 添加错误处理逻辑
} else {
// echo "voiceverify success!<br>";
// // 获取返回信息
// $voiceVerify = $result->VoiceVerify;
// echo "callSid:".$voiceVerify->callSid."<br/>";
// echo "dateCreated:".$voiceVerify->dateCreated."<br/>";
//TODO 添加成功处理逻辑
}
}
开发者ID:asmenglei,项目名称:lanxiao,代码行数:42,代码来源:sendvoicesms_helper.php
示例2: MediaFileUpload
/**
* 语音文件上传
* @param filename 文件名
* @param path 文件所在路径
*/
function MediaFileUpload($filename, $path)
{
// 初始化REST SDK
global $accountSid, $accountToken, $appId, $serverIP, $serverPort, $softVersion;
$rest = new REST($serverIP, $serverPort, $softVersion);
$rest->setAccount($accountSid, $accountToken);
$rest->setAppId($appId);
$filePath = $path;
$fh = fopen($filePath, "rb");
$body = fread($fh, filesize($filePath));
fclose($fh);
// 调用语音文件上传接口
$result = $rest->MediaFileUpload($filename, $body);
if ($result == NULL) {
echo "result error!";
break;
}
if ($result->statusCode != 0) {
echo "error code :" . $result->statusCode . "<br>";
echo "error msg :" . $result->statusMsg . "<br>";
//TODO 添加错误处理逻辑
} else {
echo "MediaFileUpload success!<br/>";
//TODO 添加成功处理逻辑
}
}
开发者ID:fengyeno,项目名称:fille,代码行数:31,代码来源:MediaFileUpload.php
示例3: sendTemplateSMS
/**
* 发送验证码 sendTemplateSMS
* @param $to
* @param $datas
* @param $tempId
* @return mixed|SimpleXMLElement|内容数据
*/
function sendTemplateSMS($to = NULL, $datas = NULL, $tempId = NULL)
{
$result = '';
if ($to && $datas && $tempId) {
$accountSid = C('API_SMS.accounts_id');
//主帐号,对应开官网发者主账号下的 ACCOUNT SID
$accountToken = C('API_SMS.account_token');
//主帐号令牌,对应官网开发者主账号下的 AUTH TOKEN
$appId = C('API_SMS.app_id');
//应用Id,在官网应用列表中点击应用,对应应用详情中的APP ID, 在开发调试的时候,可以使用官网自动为您分配的测试Demo的APP ID
$serverIP = C('API_SMS.server_ip');
//请求地址 沙盒环境(用于应用开发调试):sandboxapp.cloopen.com,生产环境(用户应用上线使用):app.cloopen.com
$serverPort = C('API_SMS.server_port');
//请求端口,生产环境和沙盒环境一致
$softVersion = C('API_SMS.soft_version');
//REST版本号,在官网文档REST介绍中获得。
import('@.ORG.CCPRestSmsSDK');
$rest = new \REST($serverIP, $serverPort, $softVersion);
$rest->setAccount($accountSid, $accountToken);
$rest->setAppId($appId);
/* 发送模板短信 */
$result = $rest->sendTemplateSMS($to, $datas, $tempId);
}
return $result;
}
开发者ID:liqihua,项目名称:yanzhihui,代码行数:32,代码来源:function.php
示例4: createSubAccount
/**
* 创建子帐号
* @param friendlyName 子帐号名称
*/
public function createSubAccount($friendlyName)
{
// 初始化REST SDK
// global $accountSid,$accountToken,$appId,$serverIP,$serverPort,$softVersion;
$rest = new \REST($this->serverIP, $this->serverPort, $this->softVersion);
$rest->setAccount($this->accountSid, $this->accountToken);
$rest->setAppId($this->appId);
// 调用云通讯平台的创建子帐号,绑定您的子帐号名称
$result = $rest->CreateSubAccount($friendlyName);
if ($result == NULL) {
return false;
}
if ($result->statusCode != 0) {
$data['status'] = $result->statusCode;
$data['msg'] = $result->statusMsg;
//TODO 添加错误处理逻辑
} else {
// 获取返回信息
$subaccount = $result->SubAccount;
$data['status'] = $result->statusCode;
$data['subAccountSid'] = $subaccount->subAccountSid;
$data['subToken'] = $subaccount->subToken;
$data['dateCreated'] = $subaccount->dateCreated;
$data['voipAccount'] = $subaccount->voipAccount;
$data['voipPwd'] = $subaccount->voipPwd;
$data['msg'] = 'success';
//TODO 把云平台子帐号信息存储在您的服务器上.
//TODO 添加成功处理逻辑
}
return $data;
}
开发者ID:fengyeno,项目名称:fille,代码行数:35,代码来源:RonglianController.class.php
示例5: sendTemplateSMS
/**
* 发送模板短信
* @param to 手机号码集合,用英文逗号分开
* @param datas 内容数据 格式为数组 例如:array('Marry','Alon'),如不需替换请填 null
* @param $tempId 模板Id,测试应用和未上线应用使用测试模板请填写1,正式应用上线后填写已申请审核通过的模板ID
*/
function sendTemplateSMS($to, $datas, $tempId)
{
// 初始化REST SDK
global $accountSid, $accountToken, $appId, $serverIP, $serverPort, $softVersion;
$rest = new REST($serverIP, $serverPort, $softVersion);
$rest->setAccount($accountSid, $accountToken);
$rest->setAppId($appId);
// 发送模板短信
echo "Sending TemplateSMS to {$to} <br/>";
$result = $rest->sendTemplateSMS($to, $datas, $tempId);
if ($result == NULL) {
return array('sign' => 0, 'msg' => 'result error!');
}
if ($result->statusCode != 0) {
//echo "模板短信发送失败!<br/>";
//echo "error code :" . $result->statusCode . "<br>";
//echo "error msg :" . $result->statusMsg . "<br>";
//TODO 添加错误处理逻辑
return array('sign' => 2, 'msg' => "error code :" . $result->statusCode . "-----error msg :" . $result->statusMsg);
} else {
//echo "模板短信发送成功!<br/>";
// 获取返回信息
//$smsmessage = $result->TemplateSMS;
//echo "dateCreated:".$smsmessage->dateCreated."<br/>";
//echo "smsMessageSid:".$smsmessage->smsMessageSid."<br/>";
//TODO 添加成功处理逻辑
return array('sign' => 1, 'msg' => "success");
}
}
开发者ID:huangzhenwen,项目名称:Shopping-Mall,代码行数:35,代码来源:SendTemplateSMS.php
示例6: queryAccountInfo
/**
* 主帐号信息查询
*/
function queryAccountInfo()
{
// 初始化REST SDK
global $accountSid, $accountToken, $appId, $serverIP, $serverPort, $softVersion;
$rest = new REST($serverIP, $serverPort, $softVersion);
$rest->setAccount($accountSid, $accountToken);
$rest->setAppId($appId);
// 调用主帐号信息查询接口
$result = $rest->queryAccountInfo();
if ($result == NULL) {
echo "result error!";
break;
}
if ($result->statusCode != 0) {
echo "error code :" . $result->statusCode . "<br>";
echo "error msg :" . $result->statusMsg . "<br>";
//TODO 添加错误处理逻辑
} else {
echo "query AccountInfo success!<br/>";
// 获取返回信息
$account = $result->Account;
echo "friendlyName:" . $account->friendlyName . "<br/>";
echo "type:" . $account->type . "<br/>";
echo "status:" . $account->status . "<br/>";
echo "dateCreated:" . $account->dateCreated . "<br/>";
echo "dateUpdated:" . $account->dateUpdated . "<br/>";
echo "balance:" . $account->balance . "<br/>";
//TODO 添加成功处理逻辑
}
}
开发者ID:fengyeno,项目名称:fille,代码行数:33,代码来源:QueryAccountInfo.php
示例7: sendTemplateSMS
/**
* 发送模板短信
* @param to 手机号码集合,用英文逗号分开
* @param datas 内容数据 格式为数组 例如:array('Marry','Alon'),如不需替换请填 null
* @param $tempId 模板Id,测试应用和未上线应用使用测试模板请填写1,正式应用上线后填写已申请审核通过的模板ID
*/
function sendTemplateSMS($to, $datas, $tempId)
{
// 初始化REST SDK
//global $accountSid, $accountToken, $appId, $serverIP, $serverPort, $softVersion;
//主帐号,对应开官网发者主账号下的 ACCOUNT SID
$accountSid = '8a48b5514a51d087014a56d235c4034a';
//主帐号令牌,对应官网开发者主账号下的 AUTH TOKEN
$accountToken = '2922e8361b734b64a6a917c110755f4b';
//应用Id,在官网应用列表中点击应用,对应应用详情中的APP ID
//在开发调试的时候,可以使用官网自动为您分配的测试Demo的APP ID
$appId = '8a48b5514a61a814014a7a16517e0ea0';
//请求地址
//沙盒环境(用于应用开发调试):sandboxapp.cloopen.com
//生产环境(用户应用上线使用):app.cloopen.com
$serverIP = 'app.cloopen.com';
//请求端口,生产环境和沙盒环境一致
$serverPort = '8883';
//REST版本号,在官网文档REST介绍中获得。
$softVersion = '2013-12-26';
$rest = new REST($serverIP, $serverPort, $softVersion);
$rest->setAccount($accountSid, $accountToken);
$rest->setAppId($appId);
// 发送模板短信
//echo "Sending TemplateSMS to $to <br/>";
$result = $rest->sendTemplateSMS($to, $datas, $tempId);
return $result;
}
开发者ID:bohemai,项目名称:rcyj,代码行数:33,代码来源:SendSMS.class.php
示例8: QuerySMSTemplate
/**
* 短信模板查询
* @param templateId 模板ID
*/
function QuerySMSTemplate($templateId)
{
// 初始化REST SDK
global $accountSid, $accountToken, $appId, $serverIP, $serverPort, $softVersion;
$rest = new REST($serverIP, $serverPort, $softVersion);
$rest->setAccount($accountSid, $accountToken);
$rest->setAppId($appId);
// 调用短信模板查询接口
$result = $rest->QuerySMSTemplate($templateId);
if ($result == NULL) {
echo "result error!";
break;
}
if ($result->statusCode != 0) {
echo "error code :" . $result->statusCode . "<br>";
echo "error msg :" . $result->statusMsg . "<br>";
//TODO 添加错误处理逻辑
} else {
$TemplateSMS = $result->TemplateSMS;
for ($i = 0; $i < count($TemplateSMS); $i++) {
echo "title:" . $TemplateSMS[$i]->title . "<br/>";
echo "content:" . $TemplateSMS[$i]->content . "<br/>";
echo "status:" . $TemplateSMS[$i]->status . "<br/>";
echo "type:" . $TemplateSMS[$i]->type . "<br/>";
echo "dateCreated:" . $TemplateSMS[$i]->dateCreated . "<br/>";
echo "dateUpdated:" . $TemplateSMS[$i]->dateUpdated . "<br/>";
echo "id:" . $TemplateSMS[$i]->id . "<br/>";
echo "<br/>";
}
}
}
开发者ID:fengyeno,项目名称:fille,代码行数:35,代码来源:QuerySMSTemplate.php
示例9: QueryCallState
/**
* 呼叫状态查询
* @param callid 呼叫Id
* @param action 查询结果通知的回调url地址
*/
function QueryCallState($callid, $action)
{
// 初始化REST SDK
global $accountSid, $accountToken, $appId, $serverIP, $serverPort, $softVersion;
$rest = new REST($serverIP, $serverPort, $softVersion);
$rest->setAccount($accountSid, $accountToken);
$rest->setAppId($appId);
// 调用呼叫状态查询接口
$result = $rest->QueryCallState($callid, $action);
if ($result == NULL) {
echo "result error!";
break;
}
if ($result->statusCode != 0) {
echo "error code :" . $result->statusCode . "<br>";
echo "error msg :" . $result->statusMsg . "<br>";
//TODO 添加错误处理逻辑
} else {
echo "QueryCallState success!<br/>";
// 获取返回信息
echo "state:" . $result->state . "<br/>";
echo "callSid:" . $result->callSid . "<br/>";
//TODO 添加成功处理逻辑
}
}
开发者ID:fengyeno,项目名称:fille,代码行数:30,代码来源:QueryCallState.php
示例10: callBack
/**
* 双向回呼
* @param from 主叫电话号码
* @param to 被叫电话号码
* @param customerSerNum 被叫侧显示的客服号码
* @param fromSerNum 主叫侧显示的号码
* @param promptTone 自定义回拨提示音
*/
function callBack($from, $to, $customerSerNum, $fromSerNum, $promptTone)
{
// 初始化REST SDK
global $appId, $subAccountSid, $subAccountToken, $voIPAccount, $voIPPassword, $serverIP, $serverPort, $softVersion;
$rest = new REST($serverIP, $serverPort, $softVersion);
$rest->setSubAccount($subAccountSid, $subAccountToken, $voIPAccount, $voIPPassword);
$rest->setAppId($appId);
// 调用回拨接口
echo "Try to make a callback,called is {$to} <br/>";
$result = $rest->callBack($from, $to, $customerSerNum, $fromSerNum, $promptTone);
if ($result == NULL) {
echo "result error!";
break;
}
if ($result->statusCode != 0) {
echo "error code :" . $result->statusCode . "<br>";
echo "error msg :" . $result->statusMsg . "<br>";
//TODO 添加错误处理逻辑
} else {
echo "callback success!<br>";
// 获取返回信息
$callback = $result->CallBack;
echo "callSid:" . $callback->callSid . "<br/>";
echo "dateCreated:" . $callback->dateCreated . "<br/>";
//TODO 添加成功处理逻辑
}
}
开发者ID:qiuai,项目名称:qieyou,代码行数:35,代码来源:CallBack.php
示例11: getSubAccounts
/**
* 获取子帐号
* @param startNo 开始的序号,默认从0开始
* @param offset 一次查询的最大条数,最小是1条,最大是100条
*/
function getSubAccounts($startNo, $offset)
{
// 初始化REST SDK
global $accountSid, $accountToken, $appId, $serverIP, $serverPort, $softVersion;
$rest = new REST($serverIP, $serverPort, $softVersion);
$rest->setAccount($accountSid, $accountToken);
$rest->setAppId($appId);
// 调用云通讯平台的获取子帐号接口
echo "Try to get subaccount list<br/>";
$result = $rest->getSubAccounts($startNo, $offset);
if ($result == NULL) {
echo "result error!";
break;
}
if ($result->statusCode != 0) {
echo "error code :" . $result->statusCode . "<br/>";
echo "error msg :" . $result->statusMsg . "<br>";
//TODO 添加错误处理逻辑
} else {
echo "get SubbAccount list success<br/>";
// 获取返回信息
$subaccount = $result->SubAccount;
for ($i = 0; $i < count($subaccount); $i++) {
echo "subAccountid:" . $subaccount[$i]->subAccountSid . "<br/>";
echo "subToken:" . $subaccount[$i]->subToken . "<br/>";
echo "dateCreated:" . $subaccount[$i]->dateCreated . "<br/>";
echo "voipAccount:" . $subaccount[$i]->voipAccount . "<br/>";
echo "voipPwd:" . $subaccount[$i]->voipPwd . "<br/>";
echo "friendlyName:" . $subaccount[$i]->friendlyName . "<br/>";
echo "<br/>";
}
//TODO 把云平台子帐号信息存储在您的服务器上.
//TODO 添加成功处理逻辑
}
}
开发者ID:fengyeno,项目名称:fille,代码行数:40,代码来源:GetSubAccounts.php
示例12: __construct
public function __construct()
{
$rest = new REST($this->serverIP, $this->serverPort, $this->softVersion);
$rest->setAccount($this->accountSid, $this->accountToken);
$rest->setAppId($this->appId);
$this->rest = $rest;
}
开发者ID:lanma121,项目名称:prize,代码行数:7,代码来源:Smssent.php
示例13: CallResult
/**
* 呼叫结果查询
* @param callSid 呼叫Id
*/
function CallResult($callSid)
{
// 初始化REST SDK
global $accountSid, $accountToken, $appId, $serverIP, $serverPort, $softVersion;
$rest = new REST($serverIP, $serverPort, $softVersion);
$rest->setAccount($accountSid, $accountToken);
$rest->setAppId($appId);
// 调用呼叫结果查询接口
$result = $rest->CallResult($callSid);
if ($result == NULL) {
echo "result error!";
break;
}
if ($result->statusCode != 0) {
echo "error code :" . $result->statusCode . "<br>";
echo "error msg :" . $result->statusMsg . "<br>";
//TODO 添加错误处理逻辑
} else {
echo "query CallResult success!<br/>";
// 获取返回信息
$callResult = $result->CallResult;
echo "friendlyName:" . $callResult->callTime . "<br/>";
echo "type:" . $callResult->state . "<br/>";
//TODO 添加成功处理逻辑
}
}
开发者ID:fengyeno,项目名称:fille,代码行数:30,代码来源:CallResult.php
示例14: voiceVerify
function voiceVerify($verifyCode, $playTimes, $to, $displayNum, $respUrl, $lang, $userData)
{
global $accountSid, $accountToken, $appId, $serverIP, $serverPort, $softVersion;
$accountSid = 'aaf98f894d`328b13014d566d3eca1b83';
$accountToken = '37fbd7a853df4704bd5420f22328fffb';
$appId = '8a48b5514d32a2a8014d56721def1b2b';
$appToken = 'd96986e70dae11e5ac73ac853d9f54f2';
$serverIP = 'sandboxapp.cloopen.com';
$serverPort = '8883';
$softVersion = '2013-12-26';
// 初始化REST SDK
global $accountSid, $accountToken, $appId, $serverIP, $serverPort, $softVersion;
$rest = new REST($serverIP, $serverPort, $softVersion);
$rest->setAccount($accountSid, $accountToken);
$rest->setAppId($appId);
//调用语音验证码接口
// echo "Try to make a voiceverify,called is $to <br/>";
$result = $rest->voiceVerify($verifyCode, $playTimes, $to, $displayNum, $respUrl, $lang, $userData);
if ($result == NULL) {
// echo "result error!";
break;
}
if ($result->statusCode != 0) {
// echo "error code :" . $result->statusCode . "<br>";
// echo "error msg :" . $result->statusMsg . "<br>";
//TODO 添加错误处理逻辑
} else {
// echo "voiceverify success!<br>";
// 获取返回信息
$voiceVerify = $result->VoiceVerify;
// echo "callSid:".$voiceVerify->callSid."<br/>";
// echo "dateCreated:".$voiceVerify->dateCreated."<br/>";
//TODO 添加成功处理逻辑
}
}
开发者ID:aimreant,项目名称:aniwear_php,代码行数:35,代码来源:SendTemplateSMS.php
示例15: sendTemplateSMS
/**
* 发送模板短信
* @param to 手机号码集合,用英文逗号分开
* @param datas 内容数据 格式为数组 例如:array('Marry','Alon'),如不需替换请填 null
* @param $tempId 模板Id,测试应用和未上线应用使用测试模板请填写1,正式应用上线后填写已申请审核通过的模板ID
*/
function sendTemplateSMS($to, $datas, $tempId)
{
// 初始化REST SDK
global $accountSid, $accountToken, $appId, $serverIP, $serverPort, $softVersion;
$rest = new REST($serverIP, $serverPort, $softVersion);
$rest->setAccount($accountSid, $accountToken);
$rest->setAppId($appId);
// 发送模板短信
// echo "Sending TemplateSMS to $to <br/>";
$result = $rest->sendTemplateSMS($to, $datas, $tempId);
if ($result == NULL) {
echo 0;
}
if ($result->statusCode != 0) {
// echo "error code :" . $result->statusCode . "<br>";
// echo "error msg :" . $result->statusMsg . "<br>";
//TODO 添加错误处理逻辑
} else {
// echo "Sendind TemplateSMS success!<br/>";
// 获取返回信息
$smsmessage = $result->TemplateSMS;
// echo "dateCreated:".$smsmessage->dateCreated."<br/>";
// echo "smsMessageSid:".$smsmessage->smsMessageSid."<br/>";
//TODO 添加成功处理逻辑
}
}
开发者ID:carriercomm,项目名称:MyHome,代码行数:32,代码来源:SendTemplateSMS.php
示例16: voiceVerify
/**
* 语音验证码
* @param verifyCode 验证码内容,为数字和英文字母,不区分大小写,长度4-8位
* @param playTimes 播放次数,1-3次
* @param to 接收号码
* @param displayNum 显示的主叫号码
* @param respUrl 语音验证码状态通知回调地址,云通讯平台将向该Url地址发送呼叫结果通知
*/
function voiceVerify($verifyCode, $playTimes, $to, $displayNum, $respUrl)
{
// 初始化REST SDK
global $accountSid, $accountToken, $appId, $serverIP, $serverPort, $softVersion;
$rest = new REST($serverIP, $serverPort, $softVersion);
$rest->setAccount($accountSid, $accountToken);
$rest->setAppId($appId);
//调用语音验证码接口
echo "Try to make a voiceverify,called is {$to} <br/>";
$result = $rest->voiceVerify($verifyCode, $playTimes, $to, $displayNum, $respUrl);
if ($result == NULL) {
echo "result error!";
break;
}
if ($result->statusCode != 0) {
echo "error code :" . $result->statusCode . "<br>";
echo "error msg :" . $result->statusMsg . "<br>";
//TODO 添加错误处理逻辑
} else {
echo "voiceverify success!<br>";
// 获取返回信息
$voiceVerify = $result->VoiceVerify;
echo "callSid:" . $voiceVerify->callSid . "<br/>";
echo "dateCreated:" . $voiceVerify->dateCreated . "<br/>";
//TODO 添加成功处理逻辑
}
}
开发者ID:qiuai,项目名称:qieyou,代码行数:35,代码来源:VoiceVerify.php
示例17: landingCall
/**
* 外呼通知
* @param to 被叫号码
* @param mediaName 语音文件名称,格式 wav。与mediaTxt不能同时为空。当不为空时mediaTxt属性失效。
* @param mediaTxt 文本内容
* @param displayNum 显示的主叫号码
* @param playTimes 循环播放次数,1-3次,默认播放1次。
* @param respUrl 外呼通知状态通知回调地址,云通讯平台将向该Url地址发送呼叫结果通知。
* @param userData 用户私有数据
* @param maxCallTime 最大通话时长
* @param speed 发音速度
* @param volume 音量
* @param pitch 音调
* @param bgsound 背景音编号
*/
function landingCall($to, $mediaName, $mediaTxt, $displayNum, $playTimes, $respUrl, $userData, $maxCallTime, $speed, $volume, $pitch, $bgsound)
{
// 初始化REST SDK
global $accountSid, $accountToken, $appId, $serverIP, $serverPort, $softVersion;
$rest = new REST($serverIP, $serverPort, $softVersion);
$rest->setAccount($accountSid, $accountToken);
$rest->setAppId($appId);
//调用外呼通知接口
echo "Try to make a landingcall,called is {$to} <br/>";
$result = $rest->landingCall($to, $mediaName, $mediaTxt, $displayNum, $playTimes, $respUrl, $userData, $maxCallTime, $speed, $volume, $pitch, $bgsound);
if ($result == NULL) {
echo "result error!";
break;
}
if ($result->statusCode != 0) {
echo "error code :" . $result->statusCode . "<br>";
echo "error msg :" . $result->statusMsg . "<br>";
//TODO 添加错误处理逻辑
} else {
echo "landingcall success!<br>";
// 获取返回信息
$landingCall = $result->LandingCall;
echo "callSid:" . $landingCall->callSid . "<br/>";
echo "dateCreated:" . $landingCall->dateCreated . "<br/>";
//TODO 添加成功处理逻辑
}
}
开发者ID:fengyeno,项目名称:fille,代码行数:42,代码来源:LandingCall.php
示例18: sendTemplateSMS
/**
* 发送模板短信
* @param to 手机号码集合,用英文逗号分开
* @param datas 内容数据 格式为数组 例如:array('Marry','Alon'),如不需替换请填 null
* @param $tempId 模板Id,测试应用和未上线应用使用测试模板请填写1,正式应用上线后填写已申请审核通过的模板ID
*/
function sendTemplateSMS($to, $datas, $tempId)
{
// 初始化REST SDK
global $accountSid, $accountToken, $appId, $serverIP, $serverPort, $softVersion;
$rest = new REST($serverIP, $serverPort, $softVersion);
$rest->setAccount($accountSid, $accountToken);
$rest->setAppId($appId);
// 发送模板短信
//echo "Sending TemplateSMS to $to <br/>";
$output = array('return' => 0);
$result = $rest->sendTemplateSMS($to, $datas, $tempId);
if ($result == NULL) {
//echo "result error!";
//break;
}
if ($result->statusCode != 0) {
//echo "error code :" . $result->statusCode . "<br>";
//echo "error msg :" . $result->statusMsg . "<br>";
//TODO 添加错误处理逻辑
if ($result->statusCode == 160021) {
$output['return'] = 1;
}
} else {
//echo "Sendind TemplateSMS success!<br/>";
// 获取返回信息
//$smsmessage = $result->TemplateSMS;
//echo "dateCreated:".$smsmessage->dateCreated."<br/>";
//echo "smsMessageSid:".$smsmessage->smsMessageSid."<br/>";
//TODO 添加成功处理逻辑
$output['return'] = 1;
}
echo json_encode($output);
exit;
}
开发者ID:h3len,项目名称:Project,代码行数:40,代码来源:SendTemplateSMS.php
示例19: billRecords
/**
* 话单下载
* @param date day 代表前一天的数据(从00:00 – 23:59);week代表前一周的数据(周一 到周日);month表示上一个月的数据(上个月表示当前月减1,如果今天是4月10号,则查询结果是3月份的数据)
* @param keywords 客户的查询条件,由客户自行定义并提供给云通讯平台。默认不填忽略此参数
*/
function billRecords($date, $keywords)
{
// 初始化REST SDK
global $accountSid, $accountToken, $appId, $serverIP, $serverPort, $softVersion;
$rest = new REST($serverIP, $serverPort, $softVersion);
$rest->setAccount($accountSid, $accountToken);
$rest->setAppId($appId);
// 调用话单下载接口
$result = $rest->billRecords($date, $keywords);
if ($result == NULL) {
echo "result error!";
break;
}
if ($result->statusCode != 0) {
echo "error code :" . $result->statusCode . "<br>";
echo "error msg :" . $result->statusMsg . "<br>";
//TODO 添加错误处理逻辑
} else {
echo "BillRecords success!<br/>";
// 获取返回信息
echo "downUrl:" . $result->downUrl . "<br/>";
echo "token:" . $result->token . "<br/>";
//TODO 添加成功处理逻辑
}
}
开发者ID:qiuai,项目名称:qieyou,代码行数:30,代码来源:BillRecords.php
示例20: createSubAccount
/**
* 创建子帐号
* @param friendlyName 子帐号名称
*/
function createSubAccount($friendlyName)
{
// 初始化REST SDK
global $accountSid, $accountToken, $appId, $serverIP, $serverPort, $softVersion;
$rest = new REST($serverIP, $serverPort, $softVersion);
$rest->setAccount($accountSid, $accountToken);
$rest->setAppId($appId);
// 调用云通讯平台的创建子帐号,绑定您的子帐号名称
echo "Try to create a subaccount, binding to user {$friendlyName} <br/>";
$result = $rest->CreateSubAccount($friendlyName);
if ($result == NULL) {
echo "result error!";
// break;
}
if ($result->statusCode != 0) {
echo "error code :" . $result->statusCode . "<br/>";
echo "error msg :" . $result->statusMsg . "<br>";
//TODO 添加错误处理逻辑
} else {
echo "create SubbAccount success<br/>";
// 获取返回信息
$subaccount = $result->SubAccount;
echo "subAccountid:" . $subaccount->subAccountSid . "<br/>";
echo "subToken:" . $subaccount->subToken . "<br/>";
echo "dateCreated:" . $subaccount->dateCreated . "<br/>";
echo "voipAccount:" . $subaccount->voipAccount . "<br/>";
echo "voipPwd:" . $subaccount->voipPwd . "<br/>";
//TODO 把云平台子帐号信息存储在您的服务器上.
//TODO 添加成功处理逻辑
}
}
开发者ID:fengyeno,项目名称:fille,代码行数:35,代码来源:CreateSubAccount+.php
注:本文中的REST类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论