guzzle-toggl

A Toggl API client based on guzzle

  • 所有者: arendjantetteroo/guzzle-toggl
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

guzzle-toggl

A Toggl API client based on Guzzle PHP

Features

  • supports complete version 8 API with API Key authentication (thanks to @dirx)
  • supports Toggl Report Api v2 (thanks to @dirx)
  • now based on guzzle 6 (thanks to @echron)

Installation

The library is available through Composer, so its easy to get it.
Simply run this to install it:

composer require ajt/guzzle-toggl

Usage

To use the Toggl API Client simply instantiate the client with the api key.
More information on the key and authentication available at https://github.com/toggl/toggl_api_docs/blob/master/chapters/authentication.md

<?php

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

use AJT\Toggl\TogglClient;
$toggl_token = ''; // Fill in your token here
$toggl_client = TogglClient::factory(array('api_key' => $toggl_token));

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

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

<?php 

$toggl_client = TogglClient::factory(array('api_key' => $toggl_token));

$workspaces = $toggl_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 

$toggl_client = TogglClient::factory(array('api_key' => $toggl_token));

//Retrieve the Command from Guzzle
$command = $toggl_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.

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

Todo

  • Add some more examples
  • Add tests
  • Add some Response models

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 Toggl API client is available under an MIT License.

主要指標

概覽
名稱與所有者arendjantetteroo/guzzle-toggl
主編程語言PHP
編程語言PHP (語言數: 1)
平台
許可證MIT License
所有者活动
創建於2013-04-17 09:29:04
推送於2024-09-04 15:22:16
最后一次提交
發布數19
最新版本名稱v2.1.0 (發布於 )
第一版名稱v0.6 (發布於 )
用户参与
星數88
關注者數9
派生數42
提交數96
已啟用問題?
問題數15
打開的問題數0
拉請求數29
打開的拉請求數0
關閉的拉請求數3
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?