當前位置: 首頁>>代碼示例>>PHP>>正文


PHP REST類代碼示例

本文整理匯總了PHP中REST的典型用法代碼示例。如果您正苦於以下問題:PHP REST類的具體用法?PHP REST怎麽用?PHP REST使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了REST類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的REST類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。