/** * 初始化 */ private function _init() { $phprpcPath = LIB_PATH . '/phprpc/phprpc_client.php'; if (!file_exists($phprpcPath)) { throw new Error('phprpc libs not exist'); } include $phprpcPath; $this->_phpRpc = new PHPRPC_Client(); $this->_phpRpc->setProxy(null); //设置代理 $this->_phpRpc->setEncryptMode(0); $this->_phpRpc->setCharset('UTF-8'); $this->_phpRpc->setTimeout(10); }
function manage_action() { if(!config::get('sms_username') || !config::get('sms_password')){ echo '<script>alert("您需要先设置用户名和密码才能使用短信管理功能!");window.location.href="'.url('config/system/set/sms').'";</script>'; exit; } include_once("phprpc/phprpc_client.php"); $client = new PHPRPC_Client(); $client->setProxy(NULL); $client->useService('http://pay.cmseasy.cn/sms.php'); $client->setKeyLength(128); $client->setEncryptMode(3); $info = $client->getInfo(config::get('sms_username'),md5(config::get('sms_password'))); $info[0] = intval($info[0]); $info[1] = intval($info[1]); $this->view->info = $info; if (front::post('submit')) { if (front::post('act') == 'test') { $rs = sendMsg(front::post('mobile'),'test'); if($rs->SendSMSResult == '0'){ front::flash('发送成功'); }else{ front::flash('发送失败,请检查用户名、密码或剩余条数'); } } }else{ if($info[0] < 50) front::flash('你的剩余短信不足50条,请及时充值'); } }
<?php include "phprpc_client.php"; $client = new PHPRPC_Client('http://129.0.0.1/work/obsidian/libs/phprpc/server.php'); $client->setTimeout(5); $client->setEncryptMode(3); try { $out = $client->HelloWorld(); echo $out; } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; }
public function actionTest() { $serverList = $this->_getGlobalData('gameser_list'); $server = $serverList[$_REQUEST['server_id']]['server_url'] . 'rpc/user'; $phprpcPath = LIB_PATH . '/phprpc/phprpc_client.php'; if (!file_exists($phprpcPath)) { throw new Error('phprpc libs not exist'); } include_once $phprpcPath; $phpRpc = new PHPRPC_Client(); $phpRpc->useService($server); $phpRpc->setProxy(null); //设置代理 $phpRpc->setEncryptMode(0); $phpRpc->setCharset('UTF-8'); $phpRpc->setTimeout(10); $phpRpc->setPrivateKey('test'); $dataList = $phpRpc->getInfo('wcj'); print_r($dataList); }
function sendMsg($mobile, $content) { $tc = file_get_contents('config/sms.tmp.php'); $tmp = explode('@', $tc); if ($tmp[0] >= config::get('sms_maxnum') && $tmp[1] == date('Y-m-d')) { front::flash('发送失败,请检查用户名、密码或剩余条数'); return; } include_once("phprpc/phprpc_client.php"); $client = new PHPRPC_Client(); $client->setProxy(NULL); $client->useService('http://pay.cmseasy.cn/sms.php'); $client->setKeyLength(128); $client->setEncryptMode(3); $keys = config::get('sms_keyword'); if ($keys != '') { $keys = explode(',', $keys); $content = str_ireplace($keys, '*', $content); } $rs = $client->sendMsg($mobile, $content, config::get('sms_username'), md5(config::get('sms_password'))); if ($rs->SendSMSResult == '0') { $num = $tmp[0] + 1; file_put_contents('config/sms.tmp.php', $num . '@' . date('Y-m-d')); } return $rs; }