/** * 子帐号信息查询 * @param friendlyName 子帐号名称 */ function querySubAccount($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 query a subaccount : {$friendlyName}<br/>"; $result = $rest->querySubAccount($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 "query SubAccount 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 添加成功处理逻辑 } }