开启辅助访问 切换到宽版

精易论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

用微信号发送消息登录论坛

新人指南 邀请好友注册 - 我关注人的新帖 教你赚取精币 - 每日签到


求职/招聘- 论坛接单- 开发者大厅

论坛版规 总版规 - 建议/投诉 - 应聘版主 - 精华帖总集 积分说明 - 禁言标准 - 有奖举报

查看: 1440|回复: 12
收起左侧

[已解决] php 函数 怎么使用麻烦给个例子

 关闭 [复制链接]
结帖率:92% (24/26)
发表于 2019-4-2 15:27:05 | 显示全部楼层 |阅读模式   内蒙古自治区巴彦淖尔市
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文件拿到接口。

回答提醒:如果本帖被关闭无法回复,您有更好的答案帮助楼主解决,请发表至 源码区 可获得加分喔。
友情提醒:本版被采纳的主题可在 申请荣誉值 页面申请荣誉值,获得 1点 荣誉值,荣誉值可兑换荣誉会员、终身vip用户组。
快捷通道:申请荣誉值无答案申请取消悬赏投诉有答案未采纳为最佳
结帖率:81% (17/21)

签到天数: 3 天

发表于 2019-4-2 15:27:06 | 显示全部楼层   广东省茂名市
php需要安装php环境运行。
你可以在服务器上安装php环境,然后上传php文件拿到接口。
回复

使用道具 举报

结帖率:50% (1/2)
发表于 2019-4-2 15:56:36 | 显示全部楼层   香港特别行政区*
易语言 调用这个?
回复

使用道具 举报

结帖率:100% (78/78)

签到天数: 4 天

发表于 2019-4-2 16:04:53 | 显示全部楼层   菲律宾
这个不就是一个PHP的 curl处理吗?都不知道你要什么直接调用不现实,可以照着翻译成易的 就是一个post请求的处理代码
回复

使用道具 举报

结帖率:92% (24/26)
 楼主| 发表于 2019-4-2 16:48:16 | 显示全部楼层   内蒙古自治区巴彦淖尔市
花脸 发表于 2019-4-2 15:57
php需要安装php环境运行。
你可以在服务器上安装php环境,然后上传php文件拿到接口。

就是不会 用 php 调用  我调用 就出错
回复

使用道具 举报

结帖率:92% (24/26)
 楼主| 发表于 2019-4-2 16:48:40 | 显示全部楼层   内蒙古自治区巴彦淖尔市
风度猫 发表于 2019-4-2 16:04
这个不就是一个PHP的 curl处理吗?都不知道你要什么直接调用不现实,可以照着翻译成易的 就是一个post请求的 ...

安装了 web 环境  调试的时候出错  不知道怎么用
回复

使用道具 举报

结帖率:100% (78/78)

签到天数: 4 天

发表于 2019-4-2 16:52:18 | 显示全部楼层   菲律宾
扣扣 发表于 2019-4-2 16:48
安装了 web 环境  调试的时候出错  不知道怎么用

出什么错上来哈
回复

使用道具 举报

结帖率:81% (17/21)

签到天数: 3 天

发表于 2019-4-2 16:57:54 | 显示全部楼层   广东省茂名市
扣扣 发表于 2019-4-2 16:48
就是不会 用 php 调用  我调用 就出错

直接浏览器打开 看看是什么错误
回复

使用道具 举报

结帖率:92% (24/26)
 楼主| 发表于 2019-4-2 17:11:29 | 显示全部楼层   内蒙古自治区巴彦淖尔市

QQ截图20190402171056.png

不知道是不是我调用 的问题
回复

使用道具 举报

结帖率:100% (78/78)

签到天数: 4 天

发表于 2019-4-2 17:12:03 | 显示全部楼层   菲律宾
37 38 46行错误  得 我给你打开看下
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 致发广告者

发布主题 收藏帖子 返回列表

sitemap| 易语言源码| 易语言教程| 易语言论坛| 诚聘英才| 易语言模块| 手机版| 广告投放| 精易论坛
拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论,本站内容均为会员发表,并不代表精易立场!
论坛帖子内容仅用于技术交流学习和研究的目的,严禁用于非法目的,否则造成一切后果自负!如帖子内容侵害到你的权益,请联系我们!
防范网络诈骗,远离网络犯罪 违法和不良信息举报电话0663-3422125,QQ: 800073686,邮箱:800073686@b.qq.com
Powered by Discuz! X3.4 揭阳市揭东区精易科技有限公司 ( 粤ICP备12094385号-1) 粤公网安备 44522102000125 增值电信业务经营许可证 粤B2-20192173

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