Ejemplo n.º 1
0
            case 'get':
                $str = '?';
                foreach ($params as $k => $v) {
                    $str .= $k . '=' . $v . '&';
                }
                $str = substr($str, 0, -1);
                $url .= $str;
                curl_setopt($curl, CURLOPT_URL, $url);
                break;
            case 'post':
                curl_setopt($curl, CURLOPT_URL, $url);
                curl_setopt($curl, CURLOPT_POST, 1);
                curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
                break;
            default:
                $result = '';
                break;
        }
        if (!isset($result)) {
            $result = curl_exec($curl);
        }
        curl_close($curl);
        return $result;
    }
}
$type = trim($argv[1]);
$server = trim($argv[2]);
$log = trim($argv[3]);
$agent = new Agent($server);
$agent->send($type, $log);