ajt/guzzle-asana 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

ajt/guzzle-asana

Composer 安装命令:

composer require ajt/guzzle-asana

包简介

Asana API client written on top of Guzzle PHP.

README 文档

README

WARNING: Api keys are being deprecated by Asana.

Asana now also has an official API library for PHP: https://github.com/Asana/php-asana

guzzle-asana

An Asana API client based on Guzzle PHP

Installation

The library is available through Composer, so its easy to get it. Simply add this to your composer.json file:

"require": {
    "ajt/guzzle-asana": "dev-master"
}

And run composer install

Use 0.9.3 for the current stable version:

"require": {
    "ajt/guzzle-asana": "0.9.3"
}

Features

Configuration - ApiKey

To use the Asana API Client simply instantiate the client with the api key. More information on the key available at http://developer.asana.com/documentation/#api_keys

<?php

require dirname(__FILE__).'/../vendor/autoload.php';

use AJT\Asana\AsanaClient;
$asana_token = ''; // Fill in your token here
$asana_client = AsanaClient::factory(array('api_key' => $asana_token));

// if you want to see what is happening, add debug => true to the factory call
$asana_client = AsanaClient::factory(array('api_key' => $asana_token, 'debug' => true)); 

Configuration - Asana Connect (Oauth2)

To use the Asana API Client with oauth you need to use the Oauth client and use the getToken method. More information about Asana connect is available at http://developer.asana.com/documentation/#AsanaConnect

See the examples/oauth.php for more information and a complete authentication example.

<?php

require dirname(__FILE__).'/../vendor/autoload.php';

use AJT\Asana\AsanaOauthClient;
$asana_client = AsanaOauthClient::factory();

// if you want to see what is happening, add debug => true to the factory call
$asana_client = AsanaOauthClient::factory(array('debug' => true)); 

Usage

Invoke Commands using our __call method (auto-complete phpDocs are included)

<?php 
// Or the AsanaOauthClient
$asana_client = AsanaClient::factory(array('api_key' => $asana_token));

$workspaces = $asana_client->getWorkspaces(array());

foreach($workspaces as $workspace){
	$id = $workspace['id'];
	print $workspace['name'] . "\n";
}

Or Use the getCommand method (in this case you need to work with the $response['data'] array:

<?php 
// Or the AsanaOauthClient
$asana_client = AsanaClient::factory(array('api_key' => $asana_token));

//Retrieve the Command from Guzzle
$command = $client->getCommand('GetWorkspaces', array());
$command->prepare();

$response = $command->execute();

$workspaces = $response['data'];

foreach($workspaces as $workspace){
	$id = $workspace['id'];
	print $workspace['name'] . "\n";
}

Examples

Copy the apikey-dist.php to apikey.php (in the root directory) and add your apikey. Afterwards you can execute the examples in the examples directory.

Available examples with their included commands:

  • attachments.php: createTask, uploadAttachment, getAttachmentsForTask, getAttachment
  • get-users.php : getUsers, getUsersWithEmail, getUser, getMe, getUsersInWorkspace
  • get-workspaces.php: getWorkspaces, getTasksForWorkspace
  • projects.php: createProject, getProject, updateProject, getProjectsInWorkspace, getProjects, deleteProjects
  • tasks.php: createTask, getTask, updateTask, deleteTask, createSubTask, getSubTasks, getTaskStories, getStory, addTaskComment, getProjectsForTask
  • tasks-and-projects.php: createTask, getProjectsInWorkspace, addProjectToTask, getProjectsForTask, removeProjectFromTask
  • tasks-followers.php: createTask, getTask, addTaskFollowers, removeTaskFollowers
  • tags.php: createTag, getTag, updateTag, getTagsInWorkspace, getTags

You can look at the services.json for details on what methods are available and what parameters are available to call them

  • ratelimit.php shows how the backoffretry plugin works

  • oauth.php is an Asana Connect example and needs to be run with a webserver. If you are on php 5.4, you can just use the internal webserver to try it out. First you need to configure the oauthparams.php file. Copy the oauthparams-dist.php file to oauthparams.php, fill in the details (get them in Asana on the Apps page by registering a new app) and then run the server.

// Run this in the examples directory and you're good to go.
php -S localhost:8888

Contributions welcome

Found a bug, open an issue, preferably with the debug output and what you did. Bugfix? Open a Pull Request and i'll look into it.

License

The Asana API client is available under an MIT License.

ajt/guzzle-asana 适用场景与选型建议

ajt/guzzle-asana 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 705 次下载、GitHub Stars 达 8, 最近一次更新时间为 2013 年 03 月 29 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 ajt/guzzle-asana 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 8
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-03-29