PHP code example of ember-devops / guzzle-toggl

1. Go to this page and download the library: Download ember-devops/guzzle-toggl library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ember-devops / guzzle-toggl example snippets




JT\Toggl\TogglClient;
$toggl_token = ''; // Fill in your token here
$toggl_client = TogglClient::factory(['api_key' => $toggl_token]);

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

 
use AJT\Toggl\TogglClient;
$toggl_client = TogglClient::factory(['api_key' => $toggl_token]);

$workspaces = $toggl_client->getWorkspaces([]);

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

 
use AJT\Toggl\TogglClient;
$toggl_client = TogglClient::factory(['api_key' => $toggl_token]);

//Retrieve the Command from Guzzle
$command = $toggl_client->getCommand('GetWorkspaces', []);
$command->prepare();

$response = $command->execute();

$workspaces = $response['data'];

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