定制 vasyaxy/trello-php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

vasyaxy/trello-php

Composer 安装命令:

composer require vasyaxy/trello-php

包简介

PHP wrapper for Trello API

README 文档

README

Latest Version Software License Total Downloads

A PHP client for consuming the Trello API.

Install

Via Composer

$ composer require vasyaxy/trello-php

Usage

This guide will help you navigate configuring the client, authenticating your users and retrieving an access token, and accessing the api on their behalf.

Full client documentation is available in the API Guide.

Make sure you have secured your Trello API keys before going further. There is a handy guide for that.

This project includes a basic example. You can run this example to test your application details. Open the example file and include your key and secret, run php -S localhost:8000 -t example, visit http://localhost:8000 in your favorite browser.

Configure the client

The Trello client needs a few configuration settings to operate successfully.

Setting Description
key Required, the application key associated with your application.
token Required when using the package to make authenticated API requests on behalf of a user.
domain Optional, default is https://trello.com.
version Optional, default is 1.
secret Required when using package to help get access tokens, the application secret associated with your application.
name Optional. This will appear on the user facing approval screen when using package to help get access tokens.
callbackUrl Required when using package to help get access tokens.
expiration Required when using package to help get access tokens.
scope Required when using package to help get access tokens.
proxy Optional setting to declare a host to use for proxy; Read more on the Guzzle Docs.

Set configuration when creating client

$client = new vasyaxy\Services\Trello\Client(array(
    'callbackUrl' => 'http://your.domain/oauth-callback-url',
    'domain' => 'https://trello.com',
    'expiration' => '3days',
    'key' => 'my-application-key',
    'name' => 'My sweet trello enabled app',
    'scope' => 'read,write',
    'secret' => 'my-application-secret',
    'token'  => 'abcdefghijklmnopqrstuvwxyz',
    'version' => '1',
    'proxy' => 'tcp://localhost:8125',
));

Set multiple configuration after creating client

$client = new vasyaxy\Services\Trello\Client(array(
    'key' => 'my-application-key',
    'name' => 'My sweet trello enabled app',
));

$config = array(
    'callbackUrl' => 'http://your.domain/oauth-callback-url',
    'expiration' => '3days',
    'scope' => 'read,write',
);

$client->addConfig($config);

Set single configuration after creating client

$client = new vasyaxy\Services\Trello\Client(array(
    'key' => 'my-application-key',
    'name' => 'My sweet trello enabled app',
));

$client->addConfig('token', 'abcdefghijklmnopqrstuvwxyz');

Authenticate your users and store access token

The Trello client is capable of assisting you in walking your users through the OAuth authorization process and providing your application with access token credentials.

This package utilizes The League's OAuth1 Trello Client to provide this assistance.

Create a basic client

$client = new vasyaxy\Services\Trello\Client(array(
    'key' => 'my-application-key',
    'secret' => 'my-application-secret',
));

Add your application's required OAuth settings

$config = array(
    'name' => 'My sweet trello enabled app',
    'callbackUrl' => 'http://your.domain/oauth-callback-url',
    'expiration' => '3days',
    'scope' => 'read,write',
);

$client->addConfig($config);

Get authorization url, then redirect your user

$authorizationUrl = $client->getAuthorizationUrl();

header('Location: ' . $authorizationUrl);

Exchange authorization token and verifier for access token

After the user approves or denies access to your application, they will be redirected to the callback url you provided. If the user approves access, the url will include oauth_token and oauth_verifier in query string parameters.

$token = $_GET['oauth_token'];
$verifier = $_GET['oauth_verifier'];

$credentials = $client->getAccessToken($token, $verifier);
$accessToken = $credentials->getIdentifier();

If successful, $credentials with be an instance of TokenCredentials. You can store the identifier within and use to authenticate requests on behalf of that user.

Use access token to make requests

$client->addConfig('token', $accessToken);

$user = $client->getCurrentUser();

Access the API with access token

Get inventory of all entities that belong to your user

$client = new vasyaxy\Services\Trello\Client(array(
    'key' => 'my-application-key',
    'token' => 'your-users-access-token',
));

$boards = $client->getCurrentUserBoards();
$cards = $client->getCurrentUserCards();
$organizations = $client->getCurrentUserOrganizations();

Most of the methods available in the API Guide require entity ids to conduct business.

Handling exceptions

When handling exceptions that result during requests to Trello using the client, a vasyaxy\Services\Trello\Exceptions\Exception will be thrown. This exception will include information from the underlying Http request/response issues, including the response body from Trello.

try {
    $board = $client->getBoard($boardId);
} catch (vasyaxy\Services\Trello\Exceptions\Exception $e) {
    $code = $e->getCode(); // Http status code from response
    $reason = $e->getMessage(); // Http status reason phrase
    $error = $e->getPrevious(); // GuzzleHttp\Exception\RequestException from http client
    $body = $e->getResponseBody(); // stdClass response body from http client
}

Testing

$ ./vendor/bin/phpunit

Contributing

Please see CONTRIBUTING for details. You can see the current PROGRESS.

Credits

License

The MIT License (MIT). Please see License File for more information.

vasyaxy/trello-php 适用场景与选型建议

vasyaxy/trello-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 15 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 12 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「client」 「trello」 「wrapper」 「trello gold」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 vasyaxy/trello-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 vasyaxy/trello-php 我们能提供哪些服务?
定制开发 / 二次开发

基于 vasyaxy/trello-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 15
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 15
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 25
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-12-01