libcast/authot-client

This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

Authot Client

v0.3.0 2017-04-11 15:36 UTC

This package is not auto-updated.

Last update: 2021-10-20 06:32:26 UTC


README

This package wraps Auhtôt API into a PHP client. Oauth2 implementation is provided.

Installation

To install, use composer:

composer require libcast/authot-client

Usage

<?php
// Http client
$httpClient = new \GuzzleHttp\Client([
    'base_uri' => 'https://app.xn--autht-9ta.com/'
]);

// Oauth2 provider
$provider = new \Libcast\OAuth2\Client\Provider\Authot([
    'clientId'          => '{authot-client-id}',
    'clientSecret'      => '{authot-client-secret}',
    'redirectUri'       => 'https://example.com/callback-url',
]);

// Create the client
$client = (new \Libcast\Authot\Oauth2\ClientFactory($httpClient, $provider))
    ->create('{access_token}');

// Submit a transcription
$transcription = $client->createWithCallback('/path/to/audio/file.mp3', 'fr', 'https://example.com/transcription-callback-url');

// Fetch a transcription by its ID
$transcription = $client->find(42647);

echo $transcription->getId();
echo $transcription->getLang();
echo $transcription->getProgress();
echo $transcription->getStatus();
echo $transcription->getTitle();
echo $transcription->isFinished();

// Get User time left
$userTimeLeft = $client->getUserTimeLeft();
echo $userTimeLeft->getTimeLeftCorrection()->format('H:i:s');
echo $userTimeLeft->getTimeLeftTranscription()->format('H:i:s');

// Export a subtitle
$subtitle = $client->export(42647, 'srt'); // Available formats: txt, xml, sjson, srt, webvtt
file_put_contents('/path/to/output/file.srt', $subtitle);

License

The MIT License (MIT). Please see License File for more information.