本文作者:温文曦

kangle二次开发专用API操作接口

温文曦 1周前 ( 11-18 21:51 ) 744 抢沙发 百度未收录
kangle二次开发专用API操作接口摘要: 请求验证的文件请求url:http://服务器IP地址(或域名):3312/api/index.phpAPI接口权限验证:每发送一条api调用,必需带的参数有:c : (contr...

请求验证的文件
请求url:http://服务器IP地址(或域名):3312/api/index.php
API接口权限验证:每发送一条api调用,必需带的参数有:

  • c : (control)表示哪个控制文件(目前有whm,cdn)

  • a : (action)表示哪个方法,以下介绍

  • r : 随机数

  • s : 秘钥,通过md5(a + skey +r)得到,如a=add,skey=test,r=888,则s=md5(addtest888)

  • 其中skey是服务器安全码



如:

  • http://192.168.1.20:3312/api/index.php?c=whm&a=add&r=888&s=8e4fc6f181bedf11c64bac3bf341ca6a




如果验证s不通过,你会得到以下的返回
  • {"result":403,"msg":"\u6743\u9650\u9519\u8bef,\u8bf7\u68c0\u67e5\u901a\u4fe1\u5b89\u5168\u7801\u662f\u5426\u6b63\u786e"}




接口的返回数据
如果接口加了json=1参数过来,你将得到json数据。如果没有,将得到xml数据。
友情提示:请最好带json=1参数过来。以后的接口默认情况下考虑输出json。
=============================================================================
获取easypanel的信息(包括了kangle的信息)
c : whm
a : info
调用成功后你将得到如下返回数据:
  • {"result":200,"server":[{"0":"kangle"}],"version":[{"0":"3.4.8"}],"type":[{"0":"enterprise"}],"os":[{"0":"windows"}],"license_id":[{"0":"73646_1387957818"}],"license_name":[{"0":"dsdds"}],"total_run":[{"0":"611038"}],"connect":[{"0":"4"}],"request":[{"0":"14105"}],"accept":[{"0":"4722"}],"vh":[{"0":"43"}],"kangle_home":[{"0":"D:\\\easypanel\\"}],"update_code":[{"0":"win_x64"}],"easypanel_version":"2.6.17"}



其中result=200表示调用成功。
version是kangle的版本
type是kangle的商业版还是免费版(enterprise  or free)
total_run 是运行时间
vh 是虚拟主机数量
connect是当前有多少请求进来。

kangle二次开发专用API操作接口 第1张 


实例http://localhost:3312/api/index.php?c=whm&a=info&r=888&s=c819ddc971b9fc174fd3739b74c3ed13
=============================================================================
获取站点的信息
c : whm
a : getVh
name : (虚拟主机名称)
如果有这个站点,则返回:

  • {"result":200,"name":"asdf","doc_root":"D:\/home\/ftp\/a\/asdf","uid":"a1017","gid":"K~w_dSjgZe9MVqb","module":"php","templete":"easypanel","subtemplete":null,"create_time":"1444195060","expire_time2":0,"status":0,"subdir_flag":"1","subdir":"wwwroot","web_quota":"1000","db_quota":"0","domain":"-1","htaccess":".htaccess","max_connect":"0","max_worker":"8","max_queue":"0","ftp":"1","log_file":"logs\/access.log","access":"access.xml","db_name":"asdf","speed_limit":"0","product_id":"0","envs":"","cs":0,"cdn":"0","ext_passwd":0,"db_type":"mysql","log_handle":"1","max_subdir":"0","flow":"0","sync_seq":0,"flow_limit":"0","ftp_connect":"0","ftp_usl":"0","ftp_dsl":"0","ip":"","port":"","certificate":null,"certificate_key":null,"ftp_subdir":null,"last_password_error":"'''0'''","password_error_count":"'''0'''","password_security":null,"ssi":"1","ignore_backup":"0","cron":"0","recordid":"10001"}




如果没有该站点,返回
  • {"result":500}





虚拟主机的参数说明
name : 主机名称
doc_root:主机的主目录
uid:系统生成(用户在服务器上的账户ID),权限控制使用。不可更改。
gid :系统账户组ID
module:是属于哪个模块,目前有php和iis两个模块。
templete,subtemplete,已废弃
create_time :创建时间
expire_time2 :过期时间
status:站点状态,0正常,1为关闭。
subdir_flag 是否允许子域名,1为允许,0为不允许
subdir 默认子目录名称
web_quota 空间大小
db_quota 数据库大小
domain :允许绑定域名数量 -1为不限
max_connect 最多连接数
max_worker 最多工作者
ftp : 是否开通ftp,1为开通,0为不开通
db_name 数据库名称(一般和主机名称等同,sql server 特殊)


注:加入参数json=1才能以json形式显示,默认为xml形式


kangle二次开发专用API操作接口 第2张


实例:http://localhost:3312/api/index.php?c=whm&a=getVh&name=yonghensq&r=888&s=2f66bdf22ef05d27272011f5a3265316&json=1
=============================================================================
创建站点
固定参数:

  • c : whm

  • a : add_vh

  • r : 随机

  • s : 秘钥

  • init : 1  //表示创建

  • name:网站账号,数据库账号,ftp账号同步

  • passwd:网站密码,数据库密码,ftp密码同步(只创建时同步)




以下为可选参数(用于发送空间的一些参数,如网页大小,数据库大小,有三种方式,第一种是发送产品ID,第二种是发送产品名称,最后一种是发送详细的参数);
第一种:发送产品ID
  • product_id:easypanel里的产品ID


[color=rgb(51, 102, 153) !important]复制代码


例:
  • http://www.kanglesoft.com:3312/api/?c=whm&a=add_vh&r=3333&s=sdfasdfsadfddaffsdf3&name=webtest&passwd=webpasswd&init=1&product_id=1



第二种:发送产品名称
  • Product_name:easypanel里的产品名称



例:
  • http://www.kanglesoft.com:3312/api/?c=whm&a=add_vh&r=3333&s=sdfasdfsadfddaffsdf3&name=webtest&passwd=webpasswd&init=1&product_name=php100



第三种:发送详细的参数:
  • cdn:是否为CDN空间,是则发送1

  • Templete:语言(html|php|iis)

  • Subtemplete:语言引擎,php52|php53|php5217

  • web_quota:网页空间大小,数字

  • db_quota:数据库大小,数字

  • db_type:数据库类型,mysql|sqlsrv

  • subdir_flag:是否允许绑定子目录,1为是

  • Subdir:默认绑定目录,可为空,例:wwwroot

  • max_subdir:最多子目录数

  • domain:需要绑定的域名,可空,默认会绑定到subdir指 定的目录下。

  • ftp:是否开启ftp,1为是

  • ftp_connect:ftp最多连接数

  • ftp_usl:ftp上传速度限制,单位kb

  • ftp_dsl:ftp下载限制。单位kb

  • access:是否启用自定义控制,如果是请输入自定义控制文件名access.xml

  • speed_limit:带宽限制,数字型,默认为不限

  • log_handle:是否开启日志析分功能,1为是

  • flow_limit:流量限制,数字型,默认不限



kangle二次开发专用API操作接口 第3张


注:200为创建成功 500重复了
实例:http://localhost:3312/api/index.php?c=whm&a=add_vh&r=888&s=7dc796167fdbd7204435e80d6445d56e&name=baibai&passwd=123456&init=1
=============================================================================
获取站点列表
a : whm
c : listVh
r : 随机数
s : 秘钥
返回样列数据(json)

  • {"result":200,"rows":[{"name":"dnsdun","doc_root":"D:\\project\\dnsdun","uid":"a1001","module":"php","templete":"easypanel","subtemplete":null,"create_time":"1408332566","expire_time2":"'''''''''''''''''''''''''''''''0'''''''''''''''''''''''''''''''","status":"0","subdir_flag":"1","subdir":"wwwroot","web_quota":"1000","db_quota":"1000","domain":"-1","htaccess":".htaccess","max_connect":"0","max_worker":"8","max_queue":"0","ftp":"0","log_file":"logs\/access.log","access":"access.xml","db_name":"dnsdun","speed_limit":"0","product_id":"0","envs":"","cs":"'''''''''''''''''''''''''''''''0'''''''''''''''''''''''''''''''","cdn":"0","ext_passwd":"'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''0'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''","db_type":"mysql","log_handle":"1","max_subdir":"0","flow":"0","sync_seq":"'''''''''''''''''''''''''''''''0'''''''''''''''''''''''''''''''","flow_limit":"0","ftp_connect":"0","ftp_usl":"0","ftp_dsl":"0","ip":"","port":"","certificate":null,"certificate_key":null,"ftp_subdir":"","last_password_error":"'0'","password_error_count":"'0'","password_security":null,"ssi":"1","ignore_backup":"0","cron":"0","recordid":"10406"},{"name":"vhmshost","doc_root":"D:\/home\/ftp\/v\/vhmshost","uid":"a1011","module":"php","templete":"easypanel","subtemplete":null,"create_time":"1437731150","expire_time2":"'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''0'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''","status":"'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''0'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''","subdir_flag":"1","subdir":"wwwroot","web_quota":"1000","db_quota":"1000","domain":"-1","htaccess":".htaccess","max_connect":"0","max_worker":"8","max_queue":"0","ftp":"1","log_file":"logs\/access.log","access":"access.xml","db_name":"vhmshost","speed_limit":"0","product_id":"0","envs":"","cs":"'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''0'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''","cdn":"0","ext_passwd":"'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''0'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''","db_type":"mysql","log_handle":"1","max_subdir":"0","flow":"0","sync_seq":"'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''0'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''","flow_limit":"0","ftp_connect":"0","ftp_usl":"0","ftp_dsl":"0","ip":"","port":"","certificate":null,"certificate_key":null,"ftp_subdir":null,"last_password_error":"'''0'''","password_error_count":"'''0'''","password_security":null,"ssi":"1","ignore_backup":"0","cron":"0","recordid":"10505"},{"name":"kangle","doc_root":"D:\/home\/ftp\/k\/kangle","uid":"a1012","module":"php","templete":"easypanel","subtemplete":null,"create_time":"1440134528","expire_time2":"1443014667.584","status":"'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''0'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''","subdir_flag":"1","subdir":"wwwroot","web_quota":"1000","db_quota":"0","domain":"-1","htaccess":".htaccess","max_connect":"0","max_worker":"8","max_queue":"0","ftp":"1","log_file":"logs\/access.log","access":"access.xml","db_name":"kangle","speed_limit":"102400","product_id":"0","envs":"","cs":"'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''0'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''","cdn":"0","ext_passwd":"'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''0'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''","db_type":"mysql","log_handle":"1","max_subdir":"0","flow":"0","sync_seq":"'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''0'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''","flow_limit":"0","ftp_connect":"0","ftp_usl":"0","ftp_dsl":"0","ip":"","port":"","certificate":null,"certificate_key":null,"ftp_subdir":null,"last_password_error":"'''0'''","password_error_count":"'''0'''","password_security":null,"ssi":"1","ignore_backup":"0","cron":"0","recordid":"10637"},{"name":"php100010","doc_root":"D:\/home\/ftp\/p\/php100010","uid":"a1013","module":"","templete":"php","subtemplete":"php52","create_time":"1441868079","expire_time2":"'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''0'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''","status":"'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''0'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''","subdir_flag":"1","subdir":"\/wwwroot","web_quota":"100","db_quota":"100","domain":"-1","htaccess":".htaccess","max_connect":"0","max_worker":"8","max_queue":"0","ftp":"1","log_file":"logs\/access.log","access":"access.xml","db_name":"php100010","speed_limit":"0","product_id":"10","envs":"","cs":"'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''0'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''","cdn":"0","ext_passwd":"'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''0'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''","db_type":"mysql","log_handle":"0","max_subdir":"0","flow":"0","sync_seq":"'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''0'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''","flow_limit":"0","ftp_connect":"0","ftp_usl":"0","ftp_dsl":"0","ip":"","port":"","certificate":null,"certificate_key":null,"ftp_subdir":null,"last_password_error":"'''0'''","password_error_count":"'''0'''","password_security":null,"ssi":"0","ignore_backup":"0","cron":"0","recordid":"10866"}]}



修改站点密码
c :whm
a : change_password
r : 随机数
s : 秘钥
name :站点名称
passwd :新的密码

例 :
  • http://localhost:3312/api/index.php?c=whm&a=change_password&name=dnsdun&passwd=kangle&json=1



返回成功:
  • {"result":200}



更改站点状态
c : whm
a : update_vh
r : 随机数
s : 秘钥
name : 站点名称
status : 新状态(0正常,1关闭)
例 :
  • http://localhost:3312/api/index.php?c=whm&a=update_vh&name=dnsdun&status=1&json=1



返回:
  • {"result":200}



删除站点
c : whm
a : del_vh
r : 随机数
s : 秘钥
name : 站点名称

成功返回:
  • {"result":200}



获取站点的数据库使用量
c : whm
a : getDbUsed
r : 随机数
s : 秘钥
name : 站点名称

例:
  • http://localhost:3312/api/index.php?c=whm&a=getDbUsed&name=dnsdun&json=1




成功返回:
  • {"result":200,"used":1000}


转载自:永恒社区

文章版权及转载声明

作者:温文曦本文地址:https://www.vience.cn/blog/530.html发布于 1周前 ( 11-18 21:51 )
文章转载或复制请以超链接形式并注明出处文曦博客

赞(6
阅读
分享

发表评论

快捷回复:

评论列表 (暂无评论,744人围观)参与讨论

还没有评论,来说两句吧...