|
10精币
以下是php文件 函数 请大佬给个 调用格式
<?php
//servers[0] = array('url'=>'http://123.123.123.123:8081/','auth_key'=>'233333333','username'=>'admin','password'=>'233333333');
//var_dump(apipost(1,'client/list','order=asc&offset=0&limit=10'));
//var_dump(listclient(1,0,2333));
function apipost($serverid,$apiurl,$data){
$data['timestamp'] = $_SERVER['REQUEST_TIME'];
$data['auth_key'] = md5($GLOBALS['servers'][$serverid]['auth_key'].$_SERVER['REQUEST_TIME']);
$data = http_build_query($data);
$url = $GLOBALS['servers'][$serverid]['url'].$apiurl;
//$url = "http://123.123.123.123:8081/client/list";
//$data = "order=asc&offset=0&limit=10";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
if ($cookie) {
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$ret = curl_exec($ch);
$httpCode = curl_getinfo($ch,CURLINFO_HTTP_CODE);
if($httpCode != 200){
return false;
}
curl_close($ch);
return json_decode($ret,true);
}
//模拟登陆方式请求api,已弃用
function apilogin($serverid){
$url = $GLOBALS['servers'][$serverid]['url'].'login/verify';
$data = http_build_query(array('username'=>$GLOBALS['servers'][$serverid]['username'],'password'=>$GLOBALS['servers'][$serverid]['password']));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
if ($cookie) {
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$ret = curl_exec($ch);
return(!strstr($ret,'incorrect'));
$httpCode = curl_getinfo($ch,CURLINFO_HTTP_CODE);
curl_close($ch);
}
function addhost($serverid,$host,$target,$header,$hostchange,$remark,$client_id){
$data = array('host'=>$host,'target'=>$target,'header'=>$header,'hostchange'=>$hostchange,'remark'=>$remark,'client_id'=>$client_id);
$apiurl = '/index/addhost/';
return apipost($serverid,$apiurl,$data);
}
function edithost($serverid,$nhost,$host,$target,$header,$hostchange,$remark,$client_id){
$data = array('nhost'=>$nhost,'host'=>$host,'target'=>$target,'header'=>$header,'hostchange'=>$hostchange,'remark'=>$remark,'client_id'=>$client_id);
$apiurl = '/index/edithost/';
return apipost($serverid,$apiurl,$data);
}
function delhost($serverid,$host){
$data = array('host'=>$host);
$apiurl = '/index/delhost/';
return apipost($serverid,$apiurl,$data);
}
function listhost($serverid,$offset,$limit,$client_id){
$data = array('offset'=>$offset,'limit'=>$limit,'client_id'=>$client_id);
$apiurl = '/index/hostlist/';
return apipost($serverid,$apiurl,$data);
}
function gethost($serverid,$host){
$data = array('host'=>$host);
$apiurl = '/index/gethost/';
return apipost($serverid,$apiurl,$data);
}
function addclient($serverid,$remark,$u,$p,$compress,$crypt,$rate_limit,$flow_limit){
$data = array('remark'=>$remark,'u'=>$u,'p'=>$p,'compress'=>$compress,'crypt'=>$crypt,'rate_limit'=>$rate_limit,'flow_limit'=>$flow_limit);
$apiurl = '/client/add/';
return apipost($serverid,$apiurl,$data);
}
function editclient($serverid,$id,$remark,$u,$p,$compress,$crypt,$rate_limit,$flow_limit){
$data = array('id'=>$id,'remark'=>$remark,'u'=>$u,'p'=>$p,'compress'=>$compress,'crypt'=>$crypt,'rate_limit'=>$rate_limit,'flow_limit'=>$flow_limit);
$apiurl = '/client/edit/';
return apipost($serverid,$apiurl,$data);
}
function changestatus($serverid,$id,$status){
$data = array('id'=>$id,'status'=>$status);
$apiurl = '/client/changestatus/';
return apipost($serverid,$apiurl,$data);
}
function delclient($serverid,$id){
$data = array('id'=>$id);
$apiurl = '/client/del/';
return apipost($serverid,$apiurl,$data);
}
function getclient($serverid,$id){
$data = array('id'=>$id);
$apiurl = '/client/getclient/';
return apipost($serverid,$apiurl,$data);
}
function listclient($serverid,$offset,$limit){
$data = array('offset'=>$offset,'limit'=>$limit);
$apiurl = '/client/list/';
return apipost($serverid,$apiurl,$data);
}
function gettunnel($serverid,$offset,$limit,$client_id,$type){
$data = array('offset'=>$offset,'limit'=>$limit,'client_id'=>$client_id,'type'=>$type);
$apiurl = '/index/gettunnel/';
return apipost($serverid,$apiurl,$data);
}
//type of tunnel:tcp udp socks5 httpProxy secret p2p
function addtunnel($serverid,$port,$target,$password,$remark,$client_id){
$data = array('port'=>$port,'target'=>$target,'password'=>$password,'remark'=>$remark,'client_id'=>$client_id);
$apiurl = '/index/add/';
return apipost($serverid,$apiurl,$data);
}
function edittunnel($serverid,$id,$port,$target,$password,$remark,$client_id){
$data = array('id'=>$id,'port'=>$port,'target'=>$target,'password'=>$password,'remark'=>$remark,'client_id'=>$client_id);
$apiurl = '/index/edit/';
return apipost($serverid,$apiurl,$data);
}
function starttunnel($serverid,$id){
$data = array('id'=>$id);
$apiurl = '/index/start/';
return apipost($serverid,$apiurl,$data);
}
function stoptunnel($serverid,$id){
$data = array('id'=>$id);
$apiurl = '/index/stop/';
return apipost($serverid,$apiurl,$data);
}
function deltunnel($serverid,$id){
$data = array('id'=>$id);
$apiurl = '/index/del/';
return apipost($serverid,$apiurl,$data);
}
function getonetunnel($serverid,$id){
$data = array('id'=>$id);
$apiurl = '/index/getonetunnel/';
return apipost($serverid,$apiurl,$data);
}
补充内容 (2019-4-2 16:49):
不是用易语言条用 这个我知道 是 php 使用这些代码 |
最佳答案
查看完整内容
php需要安装php环境运行。
你可以在服务器上安装php环境,然后上传php文件拿到接口。
|