/** * 调用接口 * * @param string $module * @param string $action * @static * @access public * @return array */ public static function call($module, $action, $params = array()) { $config = \swan\config\sw_config::get_config('data_host'); if (!isset($config['host']) || !isset($config['port'])) { throw new sw_exception('data center host or port empty.'); } $url = 'http://%s:%s/%s/?/%s'; $url = sprintf($url, $config['host'], $config['port'], $module, $action); $curl = new \swan\curl\sw_curl($url); $curl->set_params($params); $return_content = $curl->call(); if (!$return_content) { throw new sw_exception('get data from data center.'); } $data = json_decode($return_content, true); if (isset($data['code'])) { return $data; } throw new sw_exception('get data from data center.'); }
/** * 获取 logsvr 的配置 * * @static * @access public * @return array */ public static function get_logsvr_config() { return array('host' => \swan\config\sw_config::get_config('log:host'), 'port' => \swan\config\sw_config::get_config('log:port'), 'self' => \swan\config\sw_config::get_config('log:self')); }