All Projects → sbzhu → Weworkapi_php

sbzhu / Weworkapi_php

official lib of wework api

Projects that are alternatives of or similar to Weworkapi php

Mtproto Core
Telegram API JS (MTProto) client library for browser and nodejs
Stars: ✭ 242 (+7.56%)
Mutual labels:  api, lib
Mtrans
Multi-source Translation
Stars: ✭ 711 (+216%)
Mutual labels:  api, tencent
Notion Js
🤯 Notion API
Stars: ✭ 136 (-39.56%)
Mutual labels:  api, lib
Jsonapi Rb
Efficiently produce and consume JSON API documents.
Stars: ✭ 219 (-2.67%)
Mutual labels:  api
Ccxt Rest
Open Source Unified REST API of 100+ Crypto Exchange Sites (18k+ docker pulls) - https://ccxt-rest.io/
Stars: ✭ 210 (-6.67%)
Mutual labels:  api
Boleto Api
API for register and generate "Boletos"
Stars: ✭ 222 (-1.33%)
Mutual labels:  api
Seja Um Bom Junior
Stars: ✭ 228 (+1.33%)
Mutual labels:  api
Hcloud Go
A Go library for the Hetzner Cloud API
Stars: ✭ 218 (-3.11%)
Mutual labels:  api
Openapi Codegen
OpenAPI 3.0 CodeGen plus Node.js minus the Java and emojis
Stars: ✭ 224 (-0.44%)
Mutual labels:  api
Hexo Theme Doc
A documentation theme for the Hexo blog framework
Stars: ✭ 222 (-1.33%)
Mutual labels:  api
Datoji
A tiny JSON storage service. Create, Read, Update, Delete and Search JSON data.
Stars: ✭ 222 (-1.33%)
Mutual labels:  api
Alpaca
Given a web API, Generate client libraries in node, php, python, ruby
Stars: ✭ 2,447 (+987.56%)
Mutual labels:  api
Pdf Lib
Create and modify PDF documents in any JavaScript environment
Stars: ✭ 3,426 (+1422.67%)
Mutual labels:  lib
Tensei
🚀 Content management and distribution with a touch of elegance.
Stars: ✭ 217 (-3.56%)
Mutual labels:  api
Rushstack
Monorepo for tools developed by the Rush Stack community
Stars: ✭ 3,465 (+1440%)
Mutual labels:  api
Bookmarks.dev
Bookmarks and Code Snippets Manager for Developers & Co
Stars: ✭ 218 (-3.11%)
Mutual labels:  api
Api struct
API wrapper builder with response serialization
Stars: ✭ 224 (-0.44%)
Mutual labels:  api
Controller
Complete, fast and testable actions for Rack and Hanami
Stars: ✭ 221 (-1.78%)
Mutual labels:  api
Praw
PRAW, an acronym for "Python Reddit API Wrapper", is a python package that allows for simple access to Reddit's API.
Stars: ✭ 2,675 (+1088.89%)
Mutual labels:  api
Storaji
📒 The light/responsive inventory management system available on Windows, macOS and Linux.
Stars: ✭ 222 (-1.33%)
Mutual labels:  api

About

weworkapi_php 是为了简化开发者对企业微信API接口的使用而设计的,API调用库系列之php版本
包括企业API接口、消息回调处理方法、第三方开放接口等  
本库仅做示范用,并不保证完全无bug;
另外,作者会不定期更新本库,但不保证与官方API接口文档同步,因此一切以官方文档为准。

更多来自个人开发者的其它语言的库推荐:
python : https://github.com/sbzhu/weworkapi_python [email protected](企业微信团队)
ruby : https://github.com/mycolorway/wework MyColorway(个人开发者)
php : https://github.com/sbzhu/weworkapi_php [email protected](企业微信团队)
golang : https://github.com/sbzhu/weworkapi_golang [email protected](企业微信团队)
golang : https://github.com/doubliekill/EnterpriseWechatSDK [email protected](个人开发者)

Requirement

经测试,PHP 5.3.3 ~ 7.2.0 版本均可使用

Director

├── api // API 接口
│   ├── datastructure // API接口需要使用到的一些数据结构
│   ├── examples // API接口的测试用例
│   ├── README.md
│   └── src // API接口的关键逻辑
├── callback // 消息回调的一些方法
├── config.php
├── README.md
└── utils // 一些基础方法

Usage

将本项目下载到你的目录,既可直接引用相关文件  

include_once("api/src/CorpAPI.class.php");

// 实例化 API 类
$api = new CorpAPI($corpId='ww55ca070cb9b7eb22', $secret='ktmzrVIlUH0UW63zi7-JyzsgTL9NfwUhHde6or6zwQY');

try { 
    // 创建 User
    $user = new User();
    {
        $user->userid = "userid";
        $user->name = "name";
        $user->mobile = "131488888888";
        $user->email = "[email protected]";
        $user->department = array(1); 
    } 
    $api->UserCreate($user);

    // 获取User
    $user = $api->UserGet("userid");

    // 删除User
    $api->UserDelete("userid"); 
} catch {
    echo $e->getMessage() . "\n";
    $api->UserDelete("userid");
}

详细使用方法参考每个模块下的测试用例

关于token的缓存

token是需要缓存的,不能每次调用都去获取token,否则会中频率限制
在本库的设计里,token是以类里的一个变量缓存的
比如api/src/CorpAPI.class.php 里的$accessToken变量
在类的生命周期里,这个accessToken都是存在的, 当且仅当发现token过期,CorpAPI类会自动刷新token
刷新机制在 api/src/API.class.php
所以,使用时,只需要全局实例化一个CorpAPI类,不要析构它,就可一直用它调函数,不用关心 token

$api = new CorpAPI(corpid, corpsecret);
$api->dosomething()
$api->dosomething()
$api->dosomething()
....

当然,如果要更严格的做的话,建议自行修改,全局缓存token,比如存redis、存文件等,失效周期设置为2小时。

Contact us

[email protected]
[email protected]

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].