本文整理汇总了PHP中REST::setAccount方法的典型用法代码示例。如果您正苦于以下问题:PHP REST::setAccount方法的具体用法?PHP REST::setAccount怎么用?PHP REST::setAccount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类REST
的用法示例。
在下文中一共展示了REST::setAccount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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 添加成功处理逻辑
}
}
示例3: 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 添加成功处理逻辑
}
}
示例4: 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");
}
}
示例5: 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;
}
示例6: 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/>";
}
}
}
示例7: 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 添加成功处理逻辑
}
}
示例8: 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 添加成功处理逻辑
}
}
示例9: 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;
}
示例10: 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 添加成功处理逻辑
}
}
示例11: 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 添加成功处理逻辑
}
}
示例12: 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 添加成功处理逻辑
}
}
示例13: 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 添加成功处理逻辑
}
}
示例14: __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;
}
示例15: 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 添加成功处理逻辑
}
}