amh面板api模块 AMAPI-1.0 php调用实例(转载)

2014-7-1 mdoctor AMH

<?php

// amapi调用函数
function amapi($url, $amapi_pass, $amh_cmd)
{
        $data = "amapi_pass=$amapi_pass&amh_cmd=" . base64_encode($amh_cmd);
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $result = curl_exec($ch);
        $info = curl_getinfo($ch);
        curl_close($ch);
        Return array('result' => $result, 'info' => $info);
}


$url = 'http://ip:端口/index.php?c=amapi&a=call';        // 更改为您amh面板的IP与端口号
$amapi_pass = 'e6b7572998eecd897ead8c7d716a8f1f';        // 更改使用您的amapi密钥
$amh_cmd = 'amh info';                                                                // 执行amh命令
       
$data = amapi($url, $amapi_pass, $amh_cmd);
print_r($data);

?>


打印结果集如下

Array
(
    [result] => =============================================================
 [LNMP/Nginx] Amysql Host - AMH 3.0 
 http://Amysql.com

Linux:    CentOS release 5.3 (Final) - 32BIT
UpTime:   1day online.
Time:     2013-02-23 18:32:55
LA:       0.03, 0.01, 0.00
IP:       ***
CPU:      0.0%us, 2*CPU - Intel(R) Xeon(R) CPU X3450 @ 2.67GHz Intel(R) Xeon(R) CPU X3450 @ 2.67GHz
RAM:      37MB / 512MB
HD:       2GB / 20GB


    [info] => Array
        (
            [url] => http://***:8888/index.php?c=amapi&a=call
            [content_type] => text/html;charset=utf-8
            [http_code] => 200
            [header_size] => 397
            [request_size] => 216
            [filetime] => -1
            [ssl_verify_result] => 0
            [redirect_count] => 0
            [total_time] => 2.037
            [namelookup_time] => 0
            [connect_time] => 0.188
            [pretransfer_time] => 0.188
            [size_upload] => 0
            [size_download] => 414
            [speed_download] => 203
            [speed_upload] => 0
            [download_content_length] => 0
            [upload_content_length] => 0
            [starttransfer_time] => 2.037
            [redirect_time] => 0
        )

)

来源:http://amysql.com/bbs/post-209-1-1.htm

标签: amh api

发表评论:

Powered by emlog 粤ICP备15039028号-1