imper86/php-asana-api
Composer 安装命令:
composer require imper86/php-asana-api
包简介
Simple and cool PHP Asana API client
README 文档
README
Installation
Just use composer:
composer require imper86/php-asana-api
Authentication
Library has a bunch of mechanisms that allows you to forget about tokens, expirations etc. But in order to start using it you must authorize user using Oauth flow.
Create Credentials object:
$credentials = new Credentials( 'your_client_id', 'your_client_secret', 'http://localhost:8000/asana' //redirect_uri );
Create TokenRepository object:
$tokenRepository = new FileTokenRepository(__DIR__ . '/asana_tokens');
You can invent your own TokenRepository, just implement TokenRepositoryInterface. You can use your DB, Redis, or anything you want.
Create client:
$client = new Client($credentials, $tokenRepository);
Get the authorization URL, and redirect your user:
$state = 'your-random-secret-state'; header(sprintf('Location: %s', $client->auth()->authUri($state)));
After successfull authorization, user will be redirected to your redirect_uri with state and code parameters.
Verify the state and authenticate your Client:
if ($state === $_GET['state'] ?? null) { throw new Exception('CSRF?!'); } $client->authenticateWithCode($_GET['code']);
Library will use your TokenRepository to store the token, and from now on you should only care about storing user's Asana gid.
You can get that id with:
$client->getUserGid();
Usage
Just like in Auth part, create client:
$userGid = 'your-user-gid'; $client = new Client($credentials, $tokenRepository, $userGid);
From now you can use these methods on $client:
$client->organizations()->(...) $client->projects()->(...) $client->sections()->(...) $client->tags()->(...) $client->tasks()->(...) $client->teams()->(...) $client->users()->(...) $client->workspaces()->(...)
Fast example:
$projects = $client->teams()->projects()->list('teamgid');
CRUD operations naming:
- list() - GET collection
- show() - GET item
- remove() - DELETE item
- update() - PUT item
If you use IDE with typehinting such as PHPStorm, you'll easily figure it out. If not, please take a look in Resource directory
Contributing
Any help will be very appreciated.
This library is not finished, not all resources are covered. x
imper86/php-asana-api 适用场景与选型建议
imper86/php-asana-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 58 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 10 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 imper86/php-asana-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 imper86/php-asana-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 58
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-10-21