setAccount() 공개 메소드

设置主帐号
public setAccount ( string $AccountSid, string $AccountToken )
$AccountSid string 主帐号
$AccountToken string 主帐号Token
예제 #1
0
/**
 * 发送验证码 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
0
/**
 * 呼叫结果查询
 * @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
0
/**
 * 获取子帐号
 * @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 添加成功处理逻辑
    }
}
/**
 * 发送模板短信
 * @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
0
 /**
  * 创建子帐号
  * @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
0
/**
 * 短信模板查询
 * @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
0
/**
 * 话单下载
 * @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
0
/**
 * 发送模板短信
 * @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
0
/**
 * 发送模板短信
 * @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
0
/**
 * 外呼通知
 * @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
0
/**
 * 语音验证码
 * @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
0
/**
 * 创建子帐号
 * @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
0
/**
 * 语音文件上传
 * @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
0
파일: Smssent.php 프로젝트: lanma121/prize
 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
0
/**
 * 语音验证码
 * @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 添加成功处理逻辑
    }
}
예제 #16
0
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 添加成功处理逻辑
    }
}
예제 #17
0
 /**
  * 发送模板短信
  * @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;
 }
예제 #18
0
/**
 * 主帐号信息查询
 */
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 添加成功处理逻辑
    }
}
예제 #19
0
/**
 * 呼叫状态查询
 * @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 添加成功处理逻辑
    }
}
예제 #20
0
파일: CCP.php 프로젝트: pancke/yyaf
 /**
  * 初始化REST SDK
  * @return Ambigous <NULL, unknown>
  */
 public static function getRest()
 {
     $aConf = Util_Common::getConf('CCP');
     global $accountSid, $accountToken, $appId, $serverIP, $serverPort, $softVersion;
     $rest = new REST($aConf['host'], $aConf['port'], $aConf['version']);
     $rest->setAccount($aConf['sid'], $aConf['token']);
     $rest->setAppId($aConf['appid']);
     return $rest;
 }
예제 #21
0
 function getVerifyCode()
 {
     $param = json_decode(file_get_contents('php://input'), true);
     $phone = $param['phone'];
     // $phone = '13269627267';
     if (empty($phone)) {
         err_ret(-205, 'lack of param', '手机号码为空');
     }
     $model = new Model('verify_tmp');
     //查询对应手机的最后一条记录
     $sql_max = "SELECT * from verify_tmp where id = (select max(id) from verify_tmp WHERE phone = '" . $phone . "')";
     $result = $model->query($sql_max);
     if (count($result) > 0) {
         $time = time() - $result[0]['gen_time'];
         if ($time < 60) {
             //小于1分钟
             err_ret(-302, 'too many time get verifycode', '请求验证码过于频繁');
         }
     }
     //判断是否注册过
     $model = new Model('user_info');
     $where['username'] = $phone;
     $result_user_info = $model->where($where)->select();
     if (count($result_user_info) > 0) {
         err_ret(-205, 'phone number is already registered', '此手机号码已经注册过');
     }
     //生成验证码和短信模板
     $code = rand(1000, 9999);
     $data = array($code, '5');
     //发送短信验证码
     $serverIP = C('RL_ServerIP');
     $serverPort = C('RL_ServerPort');
     $softVersion = C('RL_SoftVersion');
     $accountSid = C('RL_AccountSID');
     $accountToken = C('RL_AccountToken');
     $appId = C('RL_AppID');
     $SmsId = C('RL_SMS_TEMPLATE_ID');
     $rest = new \REST($serverIP, $serverPort, $softVersion);
     $rest->setAccount($accountSid, $accountToken);
     $rest->setAppId($appId);
     $result = $rest->sendTemplateSMS($phone, $data, $SmsId);
     if ($result->statusCode != 0) {
         err_ret($result->statusCode, $result->statusMsg);
     } else {
         //生成验证码,插入数据库
         $value['phone'] = $phone;
         $value['verifycode'] = $code;
         $value['gen_time'] = time();
         M("verify_tmp")->add($value);
         http_ret(0, 'verify code send success', '验证码发送成功');
     }
 }
예제 #22
0
 /**
  * 发送模板短信
  * @param to 手机号码集合,用英文逗号分开
  * @param datas 内容数据 格式为数组 例如:array('Marry','Alon'),如不需替换请填 null
  * @param $tempId 模板Id
  */
 function sendTemplateSMS($to, $datas, $tempId)
 {
     // 初始化REST SDK
     $accountSid = '8a48b5514f1702fd014f29ec31de197a';
     //主帐号Token
     $accountToken = '1fb094b6f956426480f88e8d24f26950';
     //应用Id
     //测试用
     //$appId='aaf98f894f4900a3014f499a536a0099';
     //正式运行用,‘志愿者验证’
     $appId = '8a48b5514f49079e014f491b9911003e';
     //请求地址,格式如下,不需要写https://
     //$serverIP='sandboxapp.cloopen.com';
     $serverIP = 'app.cloopen.com';
     //请求端口
     $serverPort = '8883';
     //REST版本号
     $softVersion = '2013-12-26';
     //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 "result error!";
         // break;
         exit;
     }
     if ($result->statusCode != 0) {
         // echo "error code :" . $result->statusCode . "<br>";
         // echo "error msg :" . $result->statusMsg . "<br>";
         return 0;
     } else {
         //echo "Sendind TemplateSMS success!<br/>";
         // 获取返回信息
         //$smsmessage = $result->TemplateSMS;
         //echo "dateCreated:".$smsmessage->dateCreated."<br/>";
         //echo "smsMessageSid:".$smsmessage->smsMessageSid."<br/>";
         return 1;
     }
 }
예제 #23
0
/**
 * 发送模板短信
 * @param to 手机号码集合,用英文逗号分开
 * @param datas 内容数据 格式为数组 例如:array('Marry','Alon'),如不需替换请填 null
 * @param $tempId 模板Id,测试应用和未上线应用使用测试模板请填写1,正式应用上线后填写已申请审核通过的模板ID
 */
function sendTemplateSMS($to, $datas, $tempId)
{
    //主帐号,对应开官网发者主账号下的 ACCOUNT SID
    $accountSid = 'aaf98f8951ce5b650151d1a4aec20594';
    //主帐号令牌,对应官网开发者主账号下的 AUTH TOKEN
    $accountToken = '50e17e2463254d90aa9c39de44b8924e';
    //应用Id,在官网应用列表中点击应用,对应应用详情中的APP ID
    //在开发调试的时候,可以使用官网自动为您分配的测试Demo的APP ID
    $appId = 'aaf98f8951ce5b650151d1a6288305b3';
    //请求地址
    //沙盒环境(用于应用开发调试):sandboxapp.cloopen.com
    //生产环境(用户应用上线使用):app.cloopen.com
    $serverIP = 'sandboxapp.cloopen.com';
    //请求端口,生产环境和沙盒环境一致
    $serverPort = '8883';
    //REST版本号,在官网文档REST介绍中获得。
    $softVersion = '2013-12-26';
    $serverIP = 'sandboxapp.cloopen.com';
    // 初始化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 "result error!";
        break;
    }
    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 添加成功处理逻辑
    }
}
예제 #24
0
 public function sendTemplateSMS($to, $datas, $tempId)
 {
     //主帐号,对应开官网发者主账号下的 ACCOUNT SID
     $accountSid = ACCOUNTSID;
     //主帐号令牌,对应官网开发者主账号下的 AUTH TOKEN
     $accountToken = ACCOUNTTOKEN;
     //应用Id,在官网应用列表中点击应用,对应应用详情中的APP ID
     //在开发调试的时候,可以使用官网自动为您分配的测试Demo的APP ID
     $appId = APPID;
     //请求地址
     //沙盒环境(用于应用开发调试):sandboxapp.cloopen.com
     //生产环境(用户应用上线使用):app.cloopen.com
     $serverIP = SERVERIP;
     //请求端口,生产环境和沙盒环境一致
     $serverPort = SERVERPORT;
     //REST版本号,在官网文档REST介绍中获得。
     $softVersion = SOFTVERSION;
     //开发时注释
     $tempId = TEMPID;
     // 初始化REST SDK
     $rest = new REST($serverIP, $serverPort, $softVersion);
     $rest->setAccount($accountSid, $accountToken);
     $rest->setAppId($appId);
     // 发送模板短信
     $result = $rest->sendTemplateSMS($to, $datas, $tempId);
     if ($result == null) {
         logger("发送短信失败, mobile=" . $to . ", 短信服务器错误");
         return false;
     }
     if ($result->statusCode != 0) {
         logger("发送短信失败, mobile=" . $to . ", errcode=[" . $result->statusCode . "]" . ", errmsg=[" . $result->statusMsg . "]");
         return false;
     } else {
         // 获取返回信息
         $smsmessage = $result->TemplateSMS;
         // echo "dateCreated:" . $smsmessage->dateCreated . "<br/>";
         // echo "smsMessageSid:" . $smsmessage->smsMessageSid . "<br/>";
         //TODO 添加成功处理逻辑
         logger("发送短信成功, mobile=" . $to . ' dateCreated=' . $smsmessage->dateCreated);
         return true;
     }
 }
예제 #25
0
 /**
  * 发送文字短信
  * @param unknown $mobile
  * @param unknown $data
  * @param unknown $step
  */
 function send_text($mobile, $data, $step)
 {
     global $_CFG;
     $rest = new REST($this->config['server_domain'], $this->config['server_port'], $this->config['soft_version']);
     $rest->setAccount($this->config['account_sid'], $this->config['account_token']);
     $rest->setAppId($this->config['appId']);
     if ($this->config['debug'] == 1) {
         $rest->setLog(TRUE, ROOT_PATH . '/data/yuntongxun_sms.log');
     }
     $param = array($data['verifycode'], intval($_CFG['ecsdxt_sms_validtime'] / 60), $_CFG['service_phone']);
     // 发送模板短信
     $result = $rest->sendTemplateSMS($mobile, $param, $this->config[$step . '_tmpl']);
     if ($result == NULL) {
         return array('errcode' => 1, 'errmsg' => 'unknown error');
     }
     if ($result->statusCode != 0) {
         return array('errcode' => $result->statusCode, 'errmsg' => $result->statusMsg);
     } else {
         return true;
     }
 }
예제 #26
0
파일: send.php 프로젝트: pukingli/WxShop
/**
 * 发送模板短信
 * @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 "result error!";
        break;
    }
    if ($result->statusCode != 0) {
        /*         echo "error code :" . $result->statusCode . "<br>";
                 echo "error msg :" . $result->statusMsg . "<br>";*/
        return false;
        //TODO 添加错误处理逻辑
    } else {
        return true;
    }
}
예제 #27
0
파일: SMS.php 프로젝트: WTer/NJB
 static function SendTemplateSMS($to, $datas, $tempId)
 {
     //var_dump($to, $datas, $tempId);
     // 初始化REST SDK
     $rest = new REST(SMS::ServerIP, SMS::ServerPort, SMS::ApiVersion);
     //echo 'new rest done' . "\r\n";
     $rest->setAccount(SMS::AccountSid, SMS::AccountToken);
     //echo 'setAccount done' . "\r\n";
     $rest->setAppId(SMS::AppId);
     //var_dump($to, $datas, $tempId);
     // 发送模板短信
     $result = $rest->sendTemplateSMS($to, $datas, $tempId);
     if ($result == NULL) {
         throw new SmsException("Failed to send SMS.");
     }
     if ($result->statusCode != 0) {
         throw new SmsException("Got error response from SMS server, code:" . $result->statusCode . ", message:" . $result->statusMsg);
     } else {
         // 获取返回信息
         $smsMessage = $result->TemplateSMS;
         return array($result->statusCode, $smsMessage->smsMessageSid, $smsMessage->dateCreated);
     }
 }
예제 #28
0
function newOrderNotification($coachid, $uid)
{
    if (empty($coachid) || empty($uid)) {
        //        err_ret(-205,'lack of param','缺少参数');
        die;
    }
    $model = new Model();
    $sql = "SELECT id,name,nicker,phone FROM user_info WHERE id IN ({$uid},{$coachid})";
    $result = $model->query($sql);
    if (count($result) > 0) {
        foreach ($result as $value) {
            if ($value['id'] == $uid) {
                $userNicker = $value['nicker'];
            } else {
                if ($value['id'] == $coachid) {
                    $coachName = $value['name'];
                    $coachPhone = $value['phone'];
                }
            }
        }
        //        $coachPhone = '18612539907';
        $data = array($coachName, $userNicker);
        //发送通知
        $serverIP = C('RL_ServerIP');
        $serverPort = C('RL_ServerPort');
        $softVersion = C('RL_SoftVersion');
        $accountSid = C('RL_AccountSID');
        $accountToken = C('RL_AccountToken');
        $appId = C('RL_AppID');
        $SmsId = C('RL_SMS_ORDER_ID');
        $rest = new \REST($serverIP, $serverPort, $softVersion);
        $rest->setAccount($accountSid, $accountToken);
        $rest->setAppId($appId);
        $result_sms = $rest->sendTemplateSMS($coachPhone, $data, $SmsId);
        //        var_dump($result_sms);
    }
}
예제 #29
0
/**
 * 发送模板短信
 * @param to 手机号码集合,用英文逗号分开
 * @param datas 内容数据 格式为数组 例如:array('Marry','Alon'),如不需替换请填 null
 * @param $tempId 模板Id,测试应用和未上线应用使用测试模板请填写1,正式应用上线后填写已申请审核通过的模板ID
 */
function sendTemplateSMS($to, $datas, $tempId)
{
    // 初始化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);
    // 发送模板短信
    //echo "Sending TemplateSMS to $to <br/>";
    $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 添加错误处理逻辑
    //      }else{
    //          echo "Sendind TemplateSMS success!<br/>";
    //          // 获取返回信息
    //          $smsmessage = $result->TemplateSMS;
    //          echo "dateCreated:".$smsmessage->dateCreated."<br/>";
    //          echo "smsMessageSid:".$smsmessage->smsMessageSid."<br/>";
    //          //TODO 添加成功处理逻辑
    //      }
    return $result;
}
예제 #30
0
파일: IvrDial.php 프로젝트: fengyeno/fille
/**
 * IVR外呼
 * @param number   待呼叫号码,为Dial节点的属性
 * @param userdata 用户数据,在<startservice>通知中返回,只允许填写数字字符,为Dial节点的属性
 * @param record   是否录音,可填项为true和false,默认值为false不录音,为Dial节点的属性
 */
function ivrDial($number, $userdata, $record)
{
    // 初始化REST SDK
    global $accountSid, $accountToken, $appId, $serverIP, $serverPort, $softVersion;
    $rest = new REST($serverIP, $serverPort, $softVersion);
    $rest->setAccount($accountSid, $accountToken);
    $rest->setAppId($appId);
    // 调用IVR外呼接口
    $result = $rest->ivrDial($number, $userdata, $record);
    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 "ivrDial success!<br/>";
        //获取返回信息
        echo "callSid:" . $result->callSid . "<br/>";
        //TODO 添加成功处理逻辑
    }
}