leegoway/qy-wechat

a laravel5.2 package for qy-wechat,企业微信SDK

dev-master 2018-08-31 07:51 UTC

This package is not auto-updated.

Last update: 2019-05-29 02:12:44 UTC


README

This is a laravel5.2 package to implement Enterprise Weixin API's response.企业微信SDK,企业微信官网看这里官网.

##Installation

1 - After install Laravel framework, insert on file composer.json, inside require object this value

    {
        "require": {
            "leegoway/qy-wechat": "dev-master"
        }
    }

and execute on console:

composer install

2 - Register service provider, on file config/app.php add to providers array

Leegoway\QyWechat\QyWechatServiceProvider::class,

3 - Register alias, on file config/app.php add to aliases array

'QyWechat' => Leegoway\QyWechat\Facades\QyWechat::class,

4 - Generate config file

php artisan vendor:publish

and then you will see config file named 'qywechat.conf', modify according to your information

##Usage First of all, you should use this provider to your php file like this:

use QyWechat;

Staff Management

// Basic add staff(完成)
QyWechat::getUserStore()->add(['userId' => 'huaizhi.li', ...]);

// Multiple add Staffs (开发中)
QyWechat::getUserStore()->add([
    new Staff(['userId' => 'huaizhi.li', ...]),
    new Staff(['userId' => 'huaizhi.li1', ...])
]);

$userid = 'zhangsan.li';//企业微信后台的个人id

// Basic get one staff(完成)
QyWechat::getUserStore()->get($userid);

// Basic update one staff(完成)
QyWechat::getUserStore()->save(['userid' => 'huaizhi.li', 'name'...]);

// Basic delete one staff (完成)
QyWechat::getUserStore()->delete($userid);

// Mutiple delete  staffs (完成)
QyWechat::getUserStore()->batchdelete([$userid1, $userid2]);

Depart Management

// Basic add depart(开发中)
QyWechat::getDepartStore()->add(new Depart(['name' => '北京部门', ...]));

// Multiple add departs (开发中)
QyWechat::getDepartStore()->add([
    new Depart(['name' => '北京部门', ...]),
    new Depart(['name' => '合肥部门', ...])
]);

// Basic delete depart(开发中)
QyWechat::getDepartStore()->delete('departId');

send application messages to users(主动推送消息)

//1.后台创建应用
//2.在扩展包中创建应用,并继承AbstractAPI
//3.发送消息即可
QyWechat::getApplyStore()->sendText($users, $content);

group chat (群聊)

//1、创建群聊
QyWechat::getChatStore()->create([...]);

//2、获取群聊信息
QyWechat::getChatStore()->get($chatid);

//3、更新群聊信息
QyWechat::getChatStore()->update([...]);

Protocal

1 - http body like this

{"code": 200, "msg": "", "data": ""}

and code mean request result and data is the content; when http request success,code eq 200; when http request error,code neq 200 and msg is the reason tip.

2 - Example: Http server handle successful

{"code": 200, "msg": "", 
"data": {"userid":"ceshi.li","name":"李测试",...}

3 - Example: Http server handle failure

{"code": 400, "msg": "delete user failure! Tip: convert userid fail", "data":""}

Todos

  • api retry
  • api log and analysis

Contact

我们企业在使用,欢迎一起交流,可以联系我QQ:1062653436 Weixin:lihuaizhi_