blimp / client
PHP 客户端库,用于与 Blimp API (www.getblimp.com) 进行交互。
dev-master
2013-02-02 02:25 UTC
Requires
- php: >=5.3.2
- rmccue/requests: dev-master
This package is not auto-updated.
Last update: 2024-09-14 14:26:23 UTC
README
此库允许您使用 PHP 与 Blimp API 交互。有关 Blimp 公共 API 文档的更多信息,请访问 http://dev.getblimp.com/。如果您有任何问题或请求,请通过 [support](mailto:support@getblimp.com?subject=Blimp API PHP library) 联系我们。
许可证
MIT 许可证
安装
使用 Github
git clone git@github.com:getblimp/blimp-php
使用 Composer
{
"require": {
"blimp/client": "dev-master"
}
}
然后运行
composer install
使用前
在开始使用此库之前,您需要注册到 Blimp,并在您的 设置 中生成新的 API 密钥,如果您还没有的话,以及您的 应用程序 中的应用程序 ID 和密钥。
用法
# load the client using Composer's autoloader require_once 'vendor/autoload.php'; $client = new Blimp\Client($username, $api_key, $app_id, $app_secret); # or load the client without an autoloader require_once 'src/BlimpClient.php'; $client = new BlimpClient($username, $api_key, $app_id, $app_secret); # get all companies that I'm part of $companies = $client->get('company'); # get one company by id $companies = $client->get('company', 1); # get all projects for one company $projects = $client->get('project', null, array('company' => 1)); # get count of total projects $total_projects = $projects->meta->total_count; # Loop through all projects and print their name foreach($projects->objects as $project) { echo $project->name; } # Get all goals for a project $goals = $client.get('goal', null, array('project' => 1)); # Get all tasks for a goal $tasks = $client.get('task', null, array('goal' => 1)); # Get all comments for a task $comments = $client.get('comment', null, array('content_type' => 'todo', 'object_pk': 1)); # Get schema for all available endpoints print_r($client->schema('company')); print_r($client->schema('project')); print_r($client->schema('goal')); print_r($client->schema('task')); print_r($client->schema('comment')); print_r($client->schema('file')); print_r($client->schema('user')); # All available methods per endpoint # $client.get($resource_name); # $client.get($resource_name, $id); # $client.create($resource_name, $data); # $client.update($resource_name, $id, $data); # $client.delete($resource_name, $id); # $client.schema($resource_name);
我参与的所有公司的示例响应
{ "meta": { "limit": 20, "next": null, "offset": 0, "previous": null, "total_count": 1 }, "objects": [ { "company_users": [ { "accepted_invitation": true, "date_created": "2012-11-01T00:00:00", "date_modified": "2012-11-27T02:22:09.817265", "id": 38, "is_active": true, "role": "admin", "user": "/api/v2/user/3/" }, { "accepted_invitation": true, "date_created": "2012-11-01T00:00:00", "date_modified": "2012-11-27T02:22:09.705959", "id": 37, "is_active": true, "role": "admin", "user": "/api/v2/user/2/" }, { "accepted_invitation": true, "date_created": "2012-11-01T00:00:00", "date_modified": "2012-11-27T02:22:09.380851", "id": 39, "is_active": true, "role": "owner", "user": "/api/v2/user/1/" } ], "date_created": "2012-11-01T00:00:00", "date_modified": "2012-12-21T21:57:09.965247", "id": 1, "image_url": "", "name": "Blimp", "resource_uri": "/api/v2/company/1/", "slug": "blimp", "used_projects": 0, "used_storage": "4929882" } ] }
改进
您希望这个库还做些什么?告诉我。请随时发送 pull requests 以改进您所做的任何改进。
待办事项
- 测试