设为首页收藏本站

ZMX - IT技术交流论坛 - 无限Perfect,追求梦想 - itzmx.com

 找回密码
 注册论坛

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

用百度帐号登录

只需两步,快速登录

搜索
查看: 1962|回复: 1

easypanel ep面板api对接查询接口,可用于对接vhms,whmcs,DA等第三方虚拟主机管理系统

[复制链接]
 成长值: 249

签到天数: 4708 天

[LV.Master]伴坛终老

发表于 2022/4/12 19:07 | 显示全部楼层 |阅读模式 |Google Chrome 100.0.4896.75|Windows 10
天涯海角搜一下: 百度 谷歌 360 搜狗 有道 雅虎 必应 即刻
easypanel ep面板api对接查询接口,可用于对接vhms,whmcs,DA等第三方虚拟主机管理系统

为方便大家对接easypanel,现将easypanel的对外接口逐一贴出,让有能力的人集成或开发出比vhms更好用的管理系统。
此贴只讨论api接口相关的问题。请勿灌水。

支持多种接口,whmcs接口,whm接口,可以和多种虚拟主机管理系统通信
模拟DA接口(DA接口地址: http://ip:3312/da/),可和星外等支持DA接口的虚拟主机管理系统相接

秘钥,通过md5(a + skey +r)得到,如a=add, skey=test, r=888,则s=md5(addtest888)
这个方法我个人认为不足够安全,一旦被他人截获URL其中的秘钥就会被截获,能被利用到其他操作上,其安全性低。
建议加入时间变量以及对操作数据进行md5编码(对操作进行排序然后拼接URL然后md5加密,最后在URL后面带上加密字符串)提高安全性。

api接口地址
因easypanel自动绑定侦听了3312端口并加了泛绑定。
所以用IP或者解析到了服务器IP的域名都可以。
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不通过,你会得到以下的返回
  1. {"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
调用成功后你将得到如下返回数据:
  1. {"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是当前有多少请求进来。


获取站点的信息
c : whm
a : getVh
name : (虚拟主机名称)
如果有这个站点,则返回:
  1. {"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"}
复制代码



如果没有该站点,返回
  1. {"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 特殊)


创建站点
固定参数:
c : whm
a : add_vh
r : 随机
s : 秘钥
init : 1  //表示创建
name:网站账号,数据库账号,ftp账号同步
passwd:网站密码,数据库密码,ftp密码同步(只创建时同步)

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

例:
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:流量限制,数字型,默认不限


修改站点
固定参数:
c : whm
a : add_vh
r : 随机
s : 秘钥
edit : 1  
name:网站账号,数据库账号,ftp账号同步
passwd:网站密码,数据库密码,ftp密码同步(只创建时同步)

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

例:
http://www.kanglesoft.com:3312/api/?c=whm&a=add_vh&r=3333&s=sdfasdfsadfddaffsdf3&name=webtest&passwd=webpasswd&edit=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&edit=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:流量限制,数字型,默认不限


获取站点列表
a : whm
c : listVh
r : 随机数
s : 秘钥
返回样列数据(json)
  1. {"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

返回成功:
  1. {"result":200}
复制代码



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

成功返回:
  1. {"result":200}
复制代码



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

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


成功返回:
  1. {"result":200,"used":1000}
复制代码


欢迎光临IT技术交流论坛:http://bbs.itzmx.com/
回复

使用道具 举报

签到天数: 117 天

[LV.6]常住居民II

发表于 2022/4/17 02:46 | 显示全部楼层 |Google Chrome 95.0.4638.69|Windows 10
隐藏的这么深,难道有好东西
欢迎光临IT技术交流论坛:http://bbs.itzmx.com/
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册论坛 新浪微博账号登陆用百度帐号登录

本版积分规则

手机版|Archiver|Mail me|网站地图|IT技术交流论坛 ( 闽ICP备13013206号-7 )

GMT+8, 2024/11/24 17:31 , Processed in 0.239988 second(s), 20 queries , MemCache On.

Powered by itzmx! X3.4

© 2011- sakura

快速回复 返回顶部 返回列表