PHP code example of api-clients / travis

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

    

api-clients / travis example snippets


use React\EventLoop\Factory;
use ApiClients\Client\Travis\AsyncClient;
use ApiClients\Client\Travis\Resource\UserInterface;
use function ApiClients\Foundation\resource_pretty_print;

$loop = Factory::create();
$client = AsyncClient::create(
    $loop, 
    'your travis key from https://blog.travis-ci.com/2013-01-28-token-token-token/'
);

$client->user()->then(function (UserInterface $user) {
    resource_pretty_print($user);
});

$loop->run();


use React\EventLoop\Factory;
use ApiClients\Client\Travis\AsyncClient;
use ApiClients\Client\Travis\Resource\BroadcastInterface;
use function ApiClients\Foundation\resource_pretty_print;

$loop = Factory::create();
$client = AsyncClient::create($loop, 'your key');

$client->broadcasts()->subscribe(function (BroadcastInterface $broadcast) {
    resource_pretty_print($broadcast);
});

$loop->run();

use ApiClients\Client\Travis\Client;
use function ApiClients\Foundation\resource_pretty_print;

$client = Client::create('your travis key');

resource_pretty_print($client->user());

use ApiClients\Client\Travis\Client;
use function ApiClients\Foundation\resource_pretty_print;

$client = Client::create('your travis key');

foreach ($client->broadcasts() as $broadcast) {
    resource_pretty_print($broadcast);
};