PHP code example of ixudra / toggl

1. Go to this page and download the library: Download ixudra/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/ */

    

ixudra / toggl example snippets



    'providers'         => array(

        //...
        Ixudra\Toggl\TogglServiceProvider::class,

    ),



    'aliases'           => array(

        //...
        'Toggl'         => Ixudra\Toggl\Facades\Toggl::class,

    ),



    'toggl' => [
        'workspace'     => env('TOGGL_WORKSPACE'),
        'token'         => env('TOGGL_TOKEN'),
    ],



    // Sets the workspace ID to a new value
    Toggl::setWorkspaceId( 456 );
    // Sets the API token to a new value       
    Toggl::setApiToken( 'second_toggl_api_token' );
    
    $response = Toggl::createClient( array( 'name' => 'Test company' ) );



    $workspaceId = 123;
    $apiToken = 'your_toggl_api_token';
    $togglService = new \Ixudra\Toggl\TogglService( $workspaceId, $apiToken );



    // Return an overview of what users in the workspace are doing and have been doing
    $response = Toggl::dashboard();

    // Create a client
    $response = Toggl::createClient( array( 'name' => 'Test company' ) );

    // Get a summary information of this month for all user 
    $response = Toggl::summaryThisMonth();

    // Get a summary information of last month for one specific user 
    $response = Toggl::summaryLastMonth( array( 'user_ids' => '123' ) );



    $workspaceId = 123;
    $apiToken = 'your_toggl_api_token';
    $togglService = new \Ixudra\Toggl\TogglService( $workspaceId, $apiToken );

    // Return an overview of what users in the workspace are doing and have been doing
    $response = $togglService->dashboard();

    // Create a client
    $response = $togglService->createClient( array( 'name' => 'Test company' ) );

    // Get a summary information of this month for all user 
    $response = $togglService->summaryThisMonth();

    // Get a summary information of last month for one specific user 
    $response = $togglService->summaryLastMonth( array( 'user_ids' => '123' ) );


class_alias('Ixudra\Toggl\Facades\Toggl', 'Toggl');