可爱猫|http-sdk|官方唯一开源|完整功能支持 免费插件

admin 2021-08-05 22:41:05 600675

下载地址
说明:若不想研究源码,那么直接到下面的源码地址(码云) 下载dll文件放到可爱猫的app下即可
可爱猫5:iHttp.cat.dll 可爱猫4:http.cat.dll

直接下载最新版dll:




捐赠二维码

功能简介

   十个事件通知 [http-sdk发给你]

     * >>>  EventLogin'://新的账号登录成功/下线时
     * >>>  EventGroupMsg'://群消息事件(收到群消息时,运行这里)
     * >>>  EventFriendMsg'://私聊消息事件(收到私聊消息时,运行这里)
     * >>>  EventReceivedTransfer'://收到转账事件(收到好友转账时,运行这里)
     * >>>  EventScanCashMoney'://面对面收款(二维码收款时,运行这里)
     * >>>  EventFriendVerify'://好友请求事件(插件3.0版本及以上)
     * >>>  EventContactsChange'://朋友变动事件(插件4.0版本及以上,当前为测试版,还未启用,留以备用)
     * >>>  EventGroupMemberAdd'://群成员增加事件(新人进群)
     * >>>  EventGroupMemberDecrease'://群成员减少事件(群成员退出)
     * >>>  EventSysMsg'://系统消息事件




    三十个事件接收 [http-sdk接收你]

     * >>> SendTextMsg 发送文本消息 robot_wxid to_wxid(群/好友) msg
     * >>> SendImageMsg 发送图片消息 robot_wxid to_wxid(群/好友) msg(name            [md5值或其他唯一的名字,包含扩展名例如1.jpg], url)
     * >>> SendVideoMsg 发送视频消息 robot_wxid to_wxid(群/好友) msg(name            [md5值或其他唯一的名字,包含扩展名例如1.mp4], url)
     * >>> SendFileMsg 发送文件消息 robot_wxid to_wxid(群/好友) msg(name            [md5值或其他唯一的名字,包含扩展名例如1.txt], url)
     * >>> SendGroupMsgAndAt 发送群消息并艾特(4.4只能艾特一人) robot_wxid, group_wxid, member_wxid, member_name, msg
     * >>> SendEmojiMsg 发送动态表情 robot_wxid to_wxid(群/好友) msg(name            [md5值或其他唯一的名字,包含扩展名例如1.gif], url)
     * >>> SendLinkMsg 发送分享链接 robot_wxid, to_wxid(群/好友), msg(title, text, target_url, pic_url, icon_url)
     * >>> SendMusicMsg 发送音乐分享 robot_wxid, to_wxid(群/好友), msg(music_name, type)
     * >>> GetRobotName 取登录账号昵称 robot_wxid
     * >>> GetRobotHeadimgurl 取登录账号头像 robot_wxid
     * >>> GetLoggedAccountList 取登录账号列表 不需要参数
     * >>> GetFriendList 取好友列表 robot_wxid
     * >>> GetGroupList 取群聊列表 robot_wxid(不传返回全部机器人的)
     * >>> GetGroupMemberList 取群成员列表 robot_wxid, group_wxid
     * >>> GetGroupMemberInfo 取群成员详细 robot_wxid, group_wxid, member_wxid
     * >>> AcceptTransfer 接收好友转账 robot_wxid, to_wxid, msg
     * >>> AgreeGroupInvite 同意群聊邀请 robot_wxid, msg
     * >>> AgreeFriendVerify 同意好友请求 robot_wxid, msg
     * >>> EditFriendNote 修改好友备注 robot_wxid, to_wxid, msg
     * >>> DeleteFriend 删除好友 robot_wxid, to_wxid
     * >>> GetappInfo 取插件信息 无参数
     * >>> GetAppDir 取应用目录 无
     * >>> AddAppLogs 添加日志 msg
     * >>> ReloadApp 重载插件 无
     * >>> RemoveGroupMember 踢出群成员 robot_wxid, group_wxid, member_wxid
     * >>> EditGroupName 修改群名称 robot_wxid, group_wxid, msg
     * >>> EditGroupNotice 修改群公告 robot_wxid, group_wxid, msg
     * >>> BuildNewGroup 建立新群 robot_wxid, msg(好友Id用"|"分割)
     * >>> QuitGroup 退出群聊 robot_wxid, group_wxid
     * >>> InviteInGroup 邀请加入群聊 robot_wxid, group_wxid, to_wxid


     

群主机器人二维码

服务端demo [php]

<?php
/**
 * 可爱猫|http-sdk 完整例子
 * @author: 遗忘悠剑
 * @Date: 2020/12/20
 *
 * http://www.uera.cn/robot.php
 * http://r.iknov.com/robot.php
 * @update 2021-09-01 若插件无更新,该demo不再升级~
 * 2022-04-10 增加小爱聊天接口demo
 */

$do = isset($_REQUEST    ['do']) ? trim($_REQUEST    ['do']) : 'index';
//如果在机器人本机运行,修改为127.0.0.1或者localhost,若外网访问改为运行机器人的服务器外网ip
$robot = Robot::init('122.114.162.223', 8090);
if (!in_array($do,     ['index', 'remote', 'down']))
    exit(json_encode(    ['success' => false, 'meg' => 'do error']));
$robot->$do();

/*-------下面是逻辑功能开发区域------*/

class Robot
{

    private $host;
    private $port;
    private $authorization_file = './authorization.txt';//通信鉴权密钥存储路径
    private $authorization;

    private $robot_master =     [//机器人主人 后面的程序 你可以自由判断是否必须主人才可操作 自行发挥
        'sundreamer',
    ];
    private $events =     [//开发了新功能,就需要在对应的事件下面加入进去例如【'music' => 1】指的是点歌插件=>开启(1 开启 0 关闭)
        'EventLogin' =>     [//新的账号登录成功/下线时

        ],
        'EventGroupMsg' =>     [//群消息事件(收到群消息时,运行这里)
            'music' => 1,
            'douyin' => 1,
            'xiaoAi' => 1,
        ],
        'EventFriendMsg' =>     [//私聊消息事件(收到私聊消息时,运行这里)
            'music' => 1,
            'douyin' => 1,
            'xiaoAi' => 1,
        ],
        'EventReceivedTransfer' =>     [//收到转账事件(收到好友转账时,运行这里)
        ],
        'EventScanCashMoney' =>     [//面对面收款(二维码收款时,运行这里)

        ],
        'EventFriendVerify' =>     [//好友请求事件(插件3.0版本及以上)
        ],
        'EventContactsChange' =>     [//朋友变动事件(插件4.0版本及以上,当前为测试版,还未启用,留以备用)

        ],
        'EventGroupMemberAdd' =>     [//群成员增加事件(新人进群)
        ],
        'EventGroupMemberDecrease' =>     [//群成员减少事件(群成员退出)
        ],
        'EventSysMsg' =>     [//系统消息事件

        ],
    ];

    /**
     * @param string $host
     * @param int $port
     * @return object
     */
    public static function init($host = '127.0.0.1', $port = 8090)
    {
        return new static($host, $port);
    }

    /**
     * @param string $host
     * @param int $port
     */
    public function __construct($host = '127.0.0.1', $port = 8090)
    {
        $this->host = $host;
        $this->port = $port;
        if (!is_file($this->authorization_file))
            $this->setAuthorization();
        $this->authorization = $this->getAuthorization();
    }

    /**
     * 程序入口,返回空白Json或具有操作命令的数据
     * 该方法不需要动
     * @return string 符合可爱猫|http-sdk插件的操作数据结构json
     */
    public function index()
    {
        header("Content-type: application/json; charset=utf-8");
        date_default_timezone_set("PRC");//设置下时区
        $data = file_get_contents('php://input');//接收原始数据;
        //file_put_contents('/tmp/wxmsg.log',$data."\r\n",FILE_APPEND);//记录接收消息log
        $rec_arr = json_decode($data, true);//把接收的json转为数组
        $this->checkAuthorization();//检测通信鉴权,并维护其值
        //$resp = json_encode($this->response($rec_arr),JSON_UNESCAPED_UNICODE);
        $resp = json_encode($this->response($rec_arr));
        //file_put_contents('/tmp/wxmsg.log',$resp."\r\n",FILE_APPEND);//记录接收消息log
        echo $resp;
    }

    /**
     * 控制机器人接口
     * 该方法不需要动
     * @return string 符合openHttpApi插件的操作数据结构json
     */
    public function remote()
    {
        header("Content-type: text/html; charset=utf-8");
        date_default_timezone_set("PRC");//设置下时区
        $param =     [//若想使用同步处理,也就是你接收完事件要如何处理,那么你就要完善下面这个数组
            "event" => isset($_REQUEST    ['event']) ? trim($_REQUEST    ['event']) : "SendTextMsg",
            "robot_wxid" => isset($_REQUEST    ['robot_wxid']) ? trim($_REQUEST    ['robot_wxid']) : 'wxid_6mkmsto8tyvf52',//wxid_6mkmsto8tyvf52 wxid_5hxa04j4z6pg22
            "group_wxid" => isset($_REQUEST    ['group_wxid']) ? trim($_REQUEST    ['group_wxid']) : '18221469840@chatroom',
            "member_wxid" => isset($_REQUEST    ['member_wxid']) ? trim($_REQUEST    ['member_wxid']) : '',
            "member_name" => isset($_REQUEST    ['member_name']) ? trim($_REQUEST    ['member_name']) : '',
            "to_wxid" => isset($_REQUEST    ['to_wxid']) ? trim($_REQUEST    ['to_wxid']) : '18221469840@chatroom',
            "msg" => isset($_REQUEST    ['msg']) ? trim($_REQUEST    ['msg']) : "你好啊!"
        ];
        echo json_encode($this->request($param));
    }

    /**
     * 将收到的图片转化为下载连接(直连文件)
     * 只有该文件和可爱猫在同一台服务器时可用
     * 并且运行该文件的用户必须拥目标文件的读取权限
     * @param string $filepath 收到的图片、视频、文件消息里的路径地址(其实就是msg的值)
     */
    public function down()
    {
        ob_clean();
        $filepath = $_REQUEST    ['filepath'] ?? './favicon.ico';
        if (!file_exists($filepath)) {
            exit(json_encode(    ['success' => false, 'message' => 'file not found!']));
        }

        $fp = fopen($filepath, "r");
        $filesize = filesize($filepath);

        header("Content-type:application/octet-stream");
        header("Accept-Ranges:bytes");
        header("Accept-Length:" . $filesize);
        header("Content-Disposition: attachment; filename=" . basename($filepath));

        $buffer = 1024;
        $buffer_count = 0;
        while (!feof($fp) && $filesize - $buffer_count > 0) {
            $data = fread($fp, $buffer);
            $buffer_count += $buffer;
            echo $data;
        }
        fclose($fp);
    }

    /**
     * 命令机器人去做某事
     * @param array $param
     * @param string $authorization
     * @return string
     *
     * param
     * >>>  event 事件名称
     * >>>  robot_wxid 机器人id
     * >>>  group_wxid 群id
     * >>>  member_wxid 群艾特人id
     * >>>  member_name 群艾特人昵称
     * >>>  to_wxid 接收方(群/好友)
     * >>>  msg 消息体(str/json)
     *
     * param.event
     * >>> SendTextMsg 发送文本消息 robot_wxid to_wxid(群/好友) msg
     * >>> 下面的几个文件类型的消息path为服务器里的路径如"D:/a.jpg",会优先使用,文件不存在则使用 url(网络地址)
     * >>> SendImageMsg 发送图片消息 robot_wxid to_wxid(群/好友) msg(name    [md5值或其他唯一的名字,包含扩展名例如1.jpg], url,patch)
     * >>> SendVideoMsg 发送视频消息 robot_wxid to_wxid(群/好友) msg(name    [md5值或其他唯一的名字,包含扩展名例如1.mp4], url,patch)
     * >>> SendFileMsg 发送文件消息 robot_wxid to_wxid(群/好友) msg(name    [md5值或其他唯一的名字,包含扩展名例如1.txt], url,patch)
     * >>> SendEmojiMsg 发送动态表情 robot_wxid to_wxid(群/好友) msg(name    [md5值或其他唯一的名字,包含扩展名例如1.gif], url,patch)
     * >>> SendGroupMsgAndAt 发送群消息并艾特(4.4只能艾特一人) robot_wxid, group_wxid, member_wxid, member_name, msg
     * >>> SendLinkMsg 发送分享链接 robot_wxid, to_wxid(群/好友), msg(title, text, target_url, pic_url, icon_url)
     * >>> SendMusicMsg 发送音乐分享 robot_wxid, to_wxid(群/好友), msg(music_name, type)
     * >>> SendCardMsg 发送名片消息(被禁用) robot_wxid to_wxid(群/好友) msg(微信号)
     * >>> SendMiniApp 发送小程序 robot_wxid to_wxid(群/好友) msg(小程序消息的xml内容)
     * >>> GetRobotName 取登录账号昵称 robot_wxid
     * >>> GetRobotHeadimgurl 取登录账号头像 robot_wxid
     * >>> GetLoggedAccountList 取登录账号列表 不需要参数
     * >>> GetFriendList 取好友列表 robot_wxid msg(is_refresh,out_rawdata)//是否更新缓存 是否原始数据
     * >>> GetGroupList 取群聊列表 robot_wxid(不传返回全部机器人的),msg(is_refresh)
     * >>> GetGroupMemberList 取群成员列表 robot_wxid, group_wxid msg(is_refresh)
     * >>> GetGroupMemberInfo 取群成员详细 robot_wxid, group_wxid, member_wxid msg(is_refresh)
     * >>> AcceptTransfer 接收好友转账 robot_wxid, to_wxid, msg
     * >>> AgreeGroupInvite 同意群聊邀请 robot_wxid, msg
     * >>> AgreeFriendVerify 同意好友请求 robot_wxid, msg
     * >>> EditFriendNote 修改好友备注 robot_wxid, to_wxid, msg
     * >>> DeleteFriend 删除好友 robot_wxid, to_wxid
     * >>> GetAppInfo 取插件信息 无参数
     * >>> GetAppDir 取应用目录 无
     * >>> AddAppLogs 添加日志 msg
     * >>> ReloadApp 重载插件 无
     * >>> RemoveGroupMember 踢出群成员 robot_wxid, group_wxid, member_wxid
     * >>> EditGroupName 修改群名称 robot_wxid, group_wxid, msg
     * >>> EditGroupNotice 修改群公告 robot_wxid, group_wxid, msg
     * >>> BuildNewGroup 建立新群 robot_wxid, msg(好友Id用"|"分割)
     * >>> QuitGroup 退出群聊 robot_wxid, group_wxid
     * >>> InviteInGroup 邀请加入群聊 robot_wxid, group_wxid, to_wxid
     */
    public function request($param)
    {
        if (is_string($param    ['msg']))
            $param    ['msg'] = $this->formatEmoji($param    ['msg']);//处理emoji
        //处理完事件返回要怎么做
        $headers =     [
            'Content-Type: application/json;charset=utf-8',
        ];
        if ($this->authorization)
            $headers    [] = "Authorization:{$this->authorization}";
        $json = json_encode($param);
        echo $json;
        return json_decode($this->sendHttp($json, null, $headers), true);
    }

    /**
     * 收到机器人的信息,告诉它怎么做
     * @param array $request
     * @return string    []
     *
     * request
     * >>>  event 事件名称
     * >>>  robot_wxid 机器人id
     * >>>  robot_name 机器人昵称 一般空值
     * >>>  type 1/文本消息 3/图片消息 34/语音消息  42/名片消息  43/视频 47/动态表情 48/地理位置  49/分享链接  2000/转账 2001/红包  2002/小程序  2003/群邀请
     * >>>  from_wxid 来源群id
     * >>>  from_name 来源群名称
     * >>>  final_from_wxid 具体发消息的群成员id/私聊时用户id
     * >>>  final_from_name 具体发消息的群成员昵称/私聊时用户昵称
     * >>>  to_wxid 发给谁,往往是机器人自己(也可能别的成员收到消息)
     * >>>  money 金额,只有"EventReceivedTransfer"事件才有该参数
     * >>>  msg 消息体(str/json) 不同事件和不同type都不一样,自己去试验吧
     *
     * request.event
     * >>>  EventLogin'://新的账号登录成功/下线时
     * >>>  EventGroupMsg'://群消息事件(收到群消息时,运行这里)
     * >>>  EventFriendMsg'://私聊消息事件(收到私聊消息时,运行这里)
     * >>>  EventReceivedTransfer'://收到转账事件(收到好友转账时,运行这里)
     * >>>  EventScanCashMoney'://面对面收款(二维码收款时,运行这里)
     * >>>  EventFriendVerify'://好友请求事件(插件3.0版本及以上)
     * >>>  EventContactsChange'://朋友变动事件(插件4.0版本及以上,当前为测试版,还未启用,留以备用)
     * >>>  EventGroupMemberAdd'://群成员增加事件(新人进群)
     * >>>  EventGroupMemberDecrease'://
     */
    public function response($request)
    {
        $response =     ["event" => ""];//event空时,机器人不处理消息
        $functions = $this->events    [$request    ['event']];
        if (empty($functions))//若没处理方法,直接返回空数据告知机器人不处理即可!
            return $response;

        foreach ($functions as $func => $is_on) {
            if ($is_on) {
                $response = call_user_func(    [$this, $func], $request);
                if ($response !== false)
                    break;//只要一个成功就跳出循环
            }
        }
        //处理完事件返回要怎么做
        return $response;
    }

    public function music($request)
    {
        $key =     ['点歌', '我想听', '来一首'];
        $msg = trim($request    ['msg']);
        foreach ($key as $v) {
            if ($this->startWith($msg, $v)) {
                $name = trim(str_replace($v, '', $msg));//把 key的前缀词替换为空
                return     [
                    "event" => "SendMusicMsg",
                    "robot_wxid" => $request    ['robot_wxid'],
                    "to_wxid" => $request    ['from_wxid'] ? $request    ['from_wxid'] : $request    ['final_from_wxid'],
                    "member_wxid" => '',
                    "member_name" => '',
                    "group_wxid" => '',
                    "msg" =>     ['name' => $name, 'type' => 0],
                ];
            }
        }
        return false;
    }

    public function douyin($request)
    {
        $key =     ['抖音', '抖音视频', '抖'];
        $msg = trim($request    ['msg']);
        foreach ($key as $v) {
            if ($this->startWith($msg, $v)) {
                $dou    ['link'] = trim(str_replace($v, '', $msg));//把用户发的消息截取为url
                $dou_json = $this->sendHttp(http_build_query($dou), 'http://qsy.988g.cn/ajax/analyze.php');
                //file_put_contents('./dou_json.txt',$dou_json);
                $dou_arr = json_decode($dou_json, true);
                //var_dump($dou_arr    ['data']    ['cover']);
                //$v_file = file_get_contents('/tmp/dou/'.basename($dou_arr    ['data']    ['downurl']),$dou_arr    ['data']    ['downurl']);
                $link =     [
                    'title' => $dou_arr    ['data']    ['voidename'],
                    'text' => $dou_arr    ['data']    ['voidename'],
                    'target_url' => $dou_arr    ['data']    ['downurl'],
                    'pic_url' => $dou_arr    ['data']    ['cover'],
                    'icon_url' => $dou_arr    ['data']    ['cover'],
                ];
                //发送分享链接 robot_wxid, to_wxid(群/好友), msg(title, text, target_url, pic_url, icon_url)
                return     [
                    "event" => "SendLinkMsg",
                    "robot_wxid" => $request    ['robot_wxid'],
                    "to_wxid" => $request    ['from_wxid'] ? $request    ['from_wxid'] : $request    ['final_from_wxid'],
                    "member_wxid" => '',
                    "member_name" => '',
                    "group_wxid" => '',
                    "msg" => $link,
                ];
            }
        }
        return false;
    }

    public function xiaoAi($request)
    {
        if ($request    ['type'] != 1)
            return false;
        $api = 'http://jiuli.xiaoapi.cn';
        $must = false;
        $req_event = $request    ['event'];
        $msg = $request    ['msg'];
        if ($req_event == 'EventGroupMsg') {
            $partnner = '!\    [@at,nickname=(.*?),wxid=(.*?)\]!';
            preg_match_all($partnner, $request    ['msg'], $match);
            $at_nick_name = $at_wx_id =     [];
            if (!empty($match    [0])) {//说明被艾特了~
                foreach ($match    [0] as $k => $at) {
                    $msg = trim(str_replace($at, '', $request    ['msg']));
                    $at_nick_name    [$k] = $match    [1]    [$k];
                    $at_wx_id    [$k] = $match    [2]    [$k];
                }
                if (in_array($request    ['robot_wxid'], $at_wx_id))
                    $must = true;
                $event = 'SendGroupMsgAndAt';
            } else {
                $event = 'SendTextMsg';
            }
            $group_wxid = $request    ['from_wxid'];
        } else {
            $must = true;
            $event = 'SendTextMsg';
            $group_wxid = '';
        }
        if ($must || rand(1, 5) == 3) {//如果被艾特或者私聊必回,否则 20%的几率回复
            $api = 'http://jiuli.xiaoapi.cn/i/xiaoai_tts.php';
            $resp = file_get_contents("{$api}?msg={$msg}");
            $resps = json_decode($resp, true) ??     ['text' => ''];
            if (empty(trim($resps    ['text'])))
                return false;
            $msg = $resps    ['text'];
            return     [
                "event" => $event,
                "robot_wxid" => $request    ['robot_wxid'],
                "to_wxid" => $request    ['from_wxid'],
                "member_wxid" => $request    ['final_from_wxid'],
                "member_name" => $request    ['final_from_name'],
                "group_wxid" => $group_wxid,
                "msg" => $msg,
            ];
        }
        return false;
    }

    /**
     * 聊天内容是否以关键词xx开头
     *
     * @param string $str 聊天内容
     * @param string $pattern 关键词
     * @return boolean  true/false
     */
    public function startWith($str, $pattern)
    {
        return strpos($str, $pattern) === 0 ? true : false;
    }

    /**
     * 格式化带emoji的消息,格式化为可爱猫可展示的表情
     * @param string $str 包含emoji表情的文本
     * @return string 拼接完成以后的字符串
     */
    public function formatEmoji($str)
    {
        $strEncode = '';
        $length = mb_strlen($str, 'utf-8');
        for ($i = 0; $i < $length; $i++) {
            $_tmpStr = mb_substr($str, $i, 1, 'utf-8');
            if (strlen($_tmpStr) >= 4) {
                $strEncode .= '    [@emoji=' . trim(json_encode($_tmpStr), '"') . ']';
            } else {
                $strEncode .= $_tmpStr;
            }
        }
        return $strEncode;
    }

    /**
     * 发送 HTTP 请求
     *
     * @param string $params 请求参数,会原样发送
     * @param string $url 请求地址
     * @param array $headers 请求头
     * @param int $timeout 超时时间
     * @param string $method 请求方法 post / get
     * @return string  结果数据(Body原始数据,一般为json字符串)
     */
    public function sendHttp($params, $url = null, $headers = null, $method = 'post', $timeout = 3)
    {
        $url = $url ? $url : $this->host . ':' . $this->port;

        $curl = curl_init();
        if ('get' == strtolower($method)) {//以GET方式发送请求
            curl_setopt($curl, CURLOPT_URL, "{$url}?{$params}");
        } else {//以POST方式发送请求
            curl_setopt($curl, CURLOPT_URL, $url);
            curl_setopt($curl, CURLOPT_POST, 1);//post提交方式
            curl_setopt($curl, CURLOPT_POSTFIELDS, $params);//设置传送的参数
        }
        /* $headers 格式
        $headers =     [
            'Content-Type:application/json;charset=utf-8',
            'Authorization:Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiI5MjU3NTczMS0zMWVlLTQxM2UtYTcwZS1mMmMyNDk3Y2M4ODAiLCJqdGkiOiI0MTA4MGQ2NjZhMDY5ZjRkNjQzOTg0M2NiMDhiOWE5ZTE1YzRiNzA3ZTE0MzA1NGEyZmI4MTgxOGQ1NjYxOTc2NDczY2I5MTk1MzI5ODU1YyIsImlhdCI6MTYwOTE1MTYyNiwibmJmIjoxNjA5MTUxNjI2LCJleHAiOjE2MTE4MzAwMjMsInN1YiI6IjEiLCJzY29wZXMiOltdfQ.i0R_gQuJ6iNK8g4RaF4paBQ4GUxnoQ-0uOjEy4cc3o1_sN4imj-k5ocnHsPdV2e467XJXBmoIKGAlh1RDuKnA6ksa1arhM78YjqRRwjw5jICnQ1O8PM-hYiAOF33X32UeHujVskGgYobFmtgUERZP--69qkdlxxpgmfQBkGwE1-XJH4VjcX82xHvxtiC0O56krpmYP7N9EimVcIc6ciKV_inlM8epI8Io5JKddRppIga3e04nV5hujb0m8bN5rD32l7mOeYRyTNhZAaovbjAvjWSFrPCz4LoXXDyxUDEmfBKxUd1JFNHfdWBo3dFMCh9-MSuKdSVY0LqeKKf9FKoiYNBIETYgsdOIq_QKhoJsrumC2y_IZ6iwQEpaRrH2Y6dzUKzfisBc2dBBeFEmOIo4ZB-HajBcRNfnnue60RMCXs_GrczQ5np8P5CzhqdHomHA9VxbhyvzjO-qAB76lgaxaOVC4w7p_h74nXOY5HMMzK7_DTbwiMMGtpX2S_aN4Z2yuVEK9h0c8JBqGN-Theb7ZHznP-NTgCyBkmzx-FtF6Pmahgp7kYv6trrSNd0WdKpQn4XBaXbVKINaobtCd0QONnFcGf3svUg8Lfoyy-r3B8y7nh94-2iNBfvPlgqzwrBdhmEEMnz6oJXCscu-d9z6a8L8cQty3YgFSzNEbh1YoI'
        ];
        */
        if (!empty($headers))
            curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($curl, CURLOPT_HEADER, false);//是否打印服务器返回的header
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);//要求结果为字符串且输出到屏幕上
        curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $timeout);//设置等待时间
        $res = curl_exec($curl);//运行curl
        $err = curl_error($curl);

        if (false === $res || !empty($err)) {
            $Errno = curl_errno($curl);
            $Info = curl_getinfo($curl);
            curl_close($curl);
            print_r($Info);
            return $err . ' result: ' . $res . 'error_msg: ' . $Errno;
        }
        curl_close($curl);//关闭curl

        return $res;
    }

    /**
     * 获取headers Nginx和Apache
     * @return array
     * @author 遗忘悠剑
     */
    private function getHeaders()
    {
        $headers =     [];
        if (!function_exists('getallheaders')) {
            foreach ($_SERVER as $name => $value) {
                if (substr($name, 0, 5) == 'HTTP_') {
                    $headers    [str_replace(' ', '-',
                        ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
                }
            }
        } else {
            $headers = getallheaders();
        }
        return $headers;
    }

    /**
     * 设置Authorization并返回
     * @param string $authorization
     * @return string
     * @author 遗忘悠剑
     */
    private function setAuthorization($authorization = '')
    {
        file_put_contents($this->authorization_file, $authorization);
        $this->authorization = $authorization;
        return $this->authorization;
    }

    /**
     * 获取Authorization
     * @return string
     * @author 遗忘悠剑
     */
    private function getAuthorization()
    {
        $this->authorization = file_get_contents($this->authorization_file) ?: '';
        return $this->authorization;
    }

    /**
     * 检测Authorization并返回
     * @return string
     * @author 遗忘悠剑
     */
    private function checkAuthorization()
    {
        $headers = $this->getHeaders();
        if (!empty($headers    ['Authorization']) && $headers    ['Authorization'] != $this->getAuthorization())
            return $this->setAuthorization($headers    ['Authorization'] ?: '');
    }
}
最后于 5月前 被admin编辑 ,原因:
可爱猫?Telegram电报群 https://t.me/ikeaimao

社区声明 1、本站提供的一切软件、教程和内容信息仅限用于学习和研究目的
2、本站资源为用户分享,如有侵权请邮件与我们联系处理敬请谅解!
3、本站信息来自网络,版权争议与本站无关。您必须在下载后的24小时之内,从您的电脑或手机中彻底删除上述内容
最新回复 (1195)
  • admin 楼主 2021-8-24 只看Ta
    引用 2
    加群主机器人后,发送“可爱猫”三个字,拉你进《可爱猫开发群》
    1
  • 悦希 2021-9-10 只看Ta
    引用 3
    支持一下!
    0
  • Zone666 2021-9-10 只看Ta
    引用 4
    支持一下!
    0
  • dual 2021-9-10 只看Ta
    引用 5
    支持
    0
  • liss520 2021-9-10 只看Ta
    引用 6
    支付一下!
    0
  • xinyu 2021-9-11 只看Ta
    引用 7
    支持一下
    0
  • wxt 2021-9-13 只看Ta
    引用 8
    支持一下
    0
  • wapffu 2021-9-14 只看Ta
    引用 9
    aaa
    0
  • 781000720 2021-9-17 只看Ta
    引用 10
    支持一下
    0
  • xsqq 2021-9-17 只看Ta
    引用 11
    支持一下
    0
  • niceo 2021-9-21 只看Ta
    引用 12
    这个是那个版本
    0
  • 支持
    0
  • yukshing 2021-9-22 只看Ta
    引用 14
    支持
    0
  • lyy 2021-9-26 只看Ta
    引用 15
    支持A
    0
  • 1098768247 2021-9-26 只看Ta
    引用 16
    加油
    0
  • 1610850289 2021-9-26 只看Ta
    引用 17
    加油加油
    0
  • xujialiwy 2021-9-27 只看Ta
    引用 18
    必须赞
    0
  • epson101 2021-10-1 只看Ta
    引用 19
    必须点赞
    0
  • emiya07 2021-10-2 只看Ta
    引用 20
    支持支持
    0
  • sunshine 2021-10-5 只看Ta
    引用 21
    支持支持
    0
  • 1426209365 2021-10-5 只看Ta
    引用 22
    免费yyds 噢利给
    0
  • daxiang 2021-10-5 只看Ta
    引用 23
    真心不错的插件!
    0
  • lipanjin 2021-10-5 只看Ta
    引用 24
    真心不错的插件!
    0
  • wormshow 2021-10-6 只看Ta
    引用 25
    免费yyds 噢利给
    0
  • zzq 2021-10-9 只看Ta
    引用 26
    wr
    0
  • fanjim 2021-10-9 只看Ta
    引用 27
    谢谢邀请码
    0
  • x490927966 2021-10-10 只看Ta
    引用 28
    谢谢邀请码
    0
  • cc 2021-10-12 只看Ta
    引用 29
    谢谢
    0
  • qwe001 2021-10-12 只看Ta
    引用 30
    谢谢邀请码
    0
  • along666 2021-10-13 只看Ta
    引用 31
    谢谢一起吗
    0
  • z15423 2021-10-13 只看Ta
    引用 32
    谢谢
    0
  • lw7124168 2021-10-13 只看Ta
    引用 33
    谢谢
    0
  • 201314665 2021-10-14 只看Ta
    引用 34
    谢谢
    0
  • wangyunge 2021-10-14 只看Ta
    引用 35
    谢谢
    0
  • q489468868 2021-10-15 只看Ta
    引用 36
    谢谢邀请码
    0
  • fai1988 2021-10-15 只看Ta
    引用 37
    谢谢邀请码
    0
  • 起飞 2021-10-16 只看Ta
    引用 38
    看看
    0
  • vesugier 2021-10-16 只看Ta
    引用 39
    xeixei
    0
  • 引用 40
    感谢分享,看看
    0
  • lqbby 2021-10-26 只看Ta
    引用 41
    好好好
    0
  • Felix 2021-10-26 只看Ta
    引用 42
    感谢分享,看看
    0
  • luojunhu 2021-10-27 只看Ta
    引用 43
    6666666666666666666666666
    0
  • zmbssg 2021-10-28 只看Ta
    引用 44
    学习了,感谢大佬无私风险,谢谢
    0
  • 徐biubiu 2021-10-28 只看Ta
    引用 45
    学习了,感谢大佬无私风险,谢谢
    0
  • ggcqwer 2021-10-29 只看Ta
    引用 46
    感谢
    0
  • 引用 47
    感谢
    0
  • 91captain 2021-11-2 只看Ta
    引用 48
    新人报道
    0
  • cg777 2021-11-3 只看Ta
    引用 49
    x新人报道
    0
  • kamang 2021-11-3 只看Ta
    引用 50
    新人报道
    0
  • chrismk 2021-11-3 只看Ta
    引用 51
    新人报道
    0
  • 220021 2021-11-3 只看Ta
    引用 52
    0000
    0
  • binbin1213 2021-11-4 只看Ta
    引用 53
    感谢大佬分享。 研究一下
    0
  • alva 2021-11-5 只看Ta
    引用 54
    新手学习!
    0
  • 引用 55
    加油
    0
  • limit7 2021-11-5 只看Ta
    引用 56
    新手来学习一下
    0
  • 897123844 2021-11-5 只看Ta
    引用 57
    学习一下啊
    0
  • mengyin 2021-11-5 只看Ta
    引用 58
    我来下载拉
    0
  • yanyu 2021-11-6 只看Ta
    引用 59
    支持一下!支持一下!
    0
  • citoyfd 2021-11-6 只看Ta
    引用 60
    补偿补偿
    0
  • sfee163 2021-11-6 只看Ta
    引用 61
    支持一下!
    0
  • think1023 2021-11-8 只看Ta
    引用 62
    支持一下!
    0
  • 头都大 2021-11-8 只看Ta
    引用 63
    哈哈哈哈
    0
  • xiaoxin 2021-11-8 只看Ta
    引用 64
    支持
    0
  • 767187006 2021-11-9 只看Ta
    引用 65
    支持支持!
    0
  • hahahaha 2021-11-10 只看Ta
    引用 66
    支持一波 !!
    0
  • lvjie1996 2021-11-10 只看Ta
    引用 67
    支持一波
    0
  • jxdxr 2021-11-11 只看Ta
    引用 68
    谢谢分享
    0
  • chenyipeng 2021-11-12 只看Ta
    引用 69
    谢谢分享
    0
  • 菜鸟本菜 2021-11-15 只看Ta
    引用 70
    借鉴大佬插件,感谢分享
    0
  • kjbj 2021-11-15 只看Ta
    引用 71
    借鉴大佬插件,感谢分享
    0
  • 丶许诺 2021-11-15 只看Ta
    引用 72
    必须下载试试看咯。
    0
  • roadster 2021-11-15 只看Ta
    引用 73
    感谢大佬的分享,很有用。
    0
  • zhjscx 2021-11-15 只看Ta
    引用 74
    好像大佬
    0
  • syh3191824 2021-11-15 只看Ta
    引用 75
    新人报道
    0
  • orange 2021-11-21 只看Ta
    引用 76
    感谢
    0
  • qingxinng 2021-11-21 只看Ta
    引用 77
    新人报道
    0
  • yukuanle 2021-11-21 只看Ta
    引用 78
    新人报到
    0
  • Pampas 2021-11-22 只看Ta
    引用 79
    谢谢
    0
  • admin2 2021-11-22 只看Ta
    引用 80
    新人报到
    0
  • 小贺贺贺 2021-11-23 只看Ta
    引用 81
    0新人
    0
  • 1150916197 2021-11-23 只看Ta
    引用 82
    感谢感谢
    0
  • 9lives 2021-11-23 只看Ta
    引用 83
    新人报到
    0
  • cstopery 2021-11-23 只看Ta
    引用 84
    jygfklk
    0
  • kele 2021-11-23 只看Ta
    引用 85
    新人
    0
  • w2200 2021-11-24 只看Ta
    引用 86
    0
  • btchong 2021-11-24 只看Ta
    引用 87
    支持!
    0
  • wapmxls 2021-11-26 只看Ta
    引用 88
    321321321
    0
  • zanghf 2021-11-27 只看Ta
    引用 89
    支持 开源
    0
  • 小寒寒 2021-11-28 只看Ta
    引用 90
    支持 开源
    0
  • chunweiwan 2021-11-28 只看Ta
    引用 91
    支持 开源
    0
  • summer 2021-11-29 只看Ta
    引用 92
    谢谢 支持博主~!
    0
  • jlyjyjmw 2021-12-1 只看Ta
    引用 93
    谢谢!支持博主
    0
  • longnull 2021-12-5 只看Ta
    引用 94
    感谢
    0
  • 菜菜嗷 2021-12-6 只看Ta
    引用 95
    谢谢大佬
    0
  • 空白 2021-12-7 只看Ta
    引用 96
    谢谢大佬
    0
  • xy6538 2021-12-8 只看Ta
    引用 97
    谢谢邀请码
    0
  • terry 2021-12-8 只看Ta
    引用 98
    谢谢大佬
    0
  • lan31732 2021-12-8 只看Ta
    引用 99
    谢谢大佬
    0
  • lan31732 2021-12-8 只看Ta
    引用 100
    谢谢大佬
    0

您可以在 登录 or 注册 后,对此帖发表评论!

返回