diff --git a/README.md b/README.md index c0b9f29..44272bd 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,82 @@ # coolq-sdk-php +## 简介 +通过对 [CoolQ HTTP API 插件](https://cqhttp.cc/docs/) 插件的封装,方便phper直接调用 [CoolQ HTTP API 插件](https://cqhttp.cc/docs/) 插件的各种api。并且已集成对上报事件的封装。未来版本将加入基于 [CoolQ HTTP API 插件](https://cqhttp.cc/docs/) 开发酷Q插件的基础上报事件封装基础类。尽量做到PHP开发QQ机器人一步到位。 -- CoolQ机器人 +## 快速开始 - 基于[http插件](https://cqhttp.cc/) - - -- [CoolQ机器人后台管理](https://github.com/kilingzhang/CoolQ/tree/CoolQ) +### 安装 +#### composer快速安装(推荐) +``` +composer require kilingzhang/coolq-php-sdk +``` +#### 或在 ```composer.json``` ```require``` 字段下添加 +``` - 基于[coolq-php-sdk](https://github.com/kilingzhang/coolq-php-sdk) - - 基于[http插件](https://cqhttp.cc/) +"require:": { + ... , + "kilingzhang/coolq-php-sdk": "^1.0" + }, +``` -#更新记录 +### 基本使用 + +假设我们创建文件为 api.php, 且api.php和vendor目录为同一级目录 +``` + +->api.php +->vendor/ + +``` + +#### ```api.php``` + +``` + +use CoolQSDK\CoolQ; +use CoolQSDK\Response; + +require_once __DIR__ . '/vendor/autoload.php'; + +$CoolQ = new CoolQ('127.0.0.1:5700', 'your-access_token', 'your-secret'); + +//$CoolQ->setReturnFormat('array'); + +echo $CoolQ->getLoginInfo(); + + +``` + + + + +## 文档 + +### API 调用 +~~暂未更新~~ + +### 事件处理 +~~暂未更新~~ + +## 版本升级(针对0.5升级至1.x) +1. 命名空间更改由```CoolQSDK\CoolQSDK```更换为```CoolQSDK\CoolQ``` +2. ```new CoolQSDK('127.0.0.1',5700,'token')``` 更改为 ```new CoolQ('127.0.0.1:5700', 'your-access_token', 'your-secret')``` 新版本已做 ```token``` 与 ```access_token```兼容 +3. 删除``` $is_post ```参数 (5.0以下版本用于选择请求接口方法为```GET```还是```POST```,默认```GET```) 现在默认统一为```GET``` +4. sendXXX函数添加```$is_aysnc```字段,字段默认为false +5. ```$auto_escape```字段已做向下兼容 + + +## 框架支持 (未来计划) + +### ~~ [Laravel](https://github.com/kilingzhang/coolq-laravel-sdk) ~~ +### ~~ [Lumen](https://github.com/kilingzhang/coolq-lumen-sdk) ~~ + +## 更新记录 - 添加获取群列表 - 添加POST提交事件方式 +- 升级SDK 同步cqhttp3.x版本插件 +- 兼容cqhttp2.x版本 -#API参数描述 -[API参数描述](https://richardchien.github.io/coolq-http-api/#/API) +## API参数描述 +[API参数描述](https://cqhttp.cc/docs/) diff --git a/composer.json b/composer.json index 1c0d4ac..65b03a2 100644 --- a/composer.json +++ b/composer.json @@ -1,43 +1,39 @@ { - "name": "kilingzhang/coolq-php-sdk", - "description": "coolq-php-sdk", - "keywords": [ - "coolq", - "coolq-http-api", - "php", - "library", - "sdk" - ], - "homepage": "https://slight-sky.github.io/", - "license": "MIT", - "authors": [ - { - "name": "kilingzhang", - "email": "slight@kilingzhang.com", - "homepage" : "https://blog.kilingzhang.com/" - } - ], - "require:": { - "php": ">=5.5", - "guzzlehttp/guzzle": "^6.0", - "psr/log": "^1.0" - }, - "require-dev": { - "phpunit/phpunit": "~6.0", - "mockery/mockery": "^1.0" - }, - "autoload": { - "psr-4": { - "CoolQSDK\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "CoolQSDK\\Tests\\": "tests/" - } - }, - "require": { - "guzzlehttp/guzzle": "~6.0", - "psr/log": "^1.0" + "name": "kilingzhang/coolq-php-sdk", + "description": "coolq-php-sdk", + "keywords": [ + "coolq", + "coolq-http-api", + "php", + "library", + "sdk" + ], + "homepage": "https://slight-sky.github.io/", + "license": "MIT", + "authors": [ + { + "name": "kilingzhang", + "email": "slight@kilingzhang.com", + "homepage": "https://blog.kilingzhang.com/" } + ], + "require": { + "php": ">=5.5", + "guzzlehttp/guzzle": "^6.0", + "psr/log": "^1.0" + }, + "require-dev": { + "phpunit/phpunit": "~6.0", + "mockery/mockery": "^1.0" + }, + "autoload": { + "psr-4": { + "CoolQSDK\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "CoolQSDK\\Tests\\": "tests/" + } + } } diff --git a/tests/index.php b/tests/index.php index 15832be..ead6401 100644 --- a/tests/index.php +++ b/tests/index.php @@ -13,7 +13,6 @@ include __DIR__ . '/../vendor/autoload.php'; - $CoolQ = new CoolQ('127.0.0.1:5700', 'kilingzhang', 'kilingzhang'); //$CoolQ->setReturnFormat('array'); //194233857