onlineuniconverter / onlineuniconverter-php
PHP SDK for OnlineUniConverter APIs
Requires
- php: ^7.2|^8.0
- guzzlehttp/psr7: ^1.0
- netresearch/jsonmapper: ^4.0
- php-http/client-common: ^2.0
- php-http/client-implementation: ^1.0 || ^2.0
- php-http/discovery: ^1.0
- php-http/httplug: ^1.0 || ^2.0
- php-http/message: ^1.7
- php-http/message-factory: ^1.0
- php-http/multipart-stream-builder: ^1.0
- psr/http-message: ^1.0
- symfony/options-resolver: ^4.2 || ^5.0
Requires (Dev)
- guzzlehttp/guzzle: 7.0
- php-http/mock-client: ^1.0
- phpunit/phpunit: 8.0
This package is auto-updated.
Last update: 2025-03-07 18:25:13 UTC
README
This is the official PHP SDK v2 for the OnlineUniConverter API v2.
Install
To install the PHP SDK you will need to be using Composer in your project.
Install the SDK alongside Guzzle 7:
composer require onlineuniconverter/onlineuniconverter-php
This package is not tied to any specific HTTP client. Instead, it uses Httplug to let users choose whichever HTTP client they want to use.
If you want to use Guzzle 6 instead, use:
composer require onlineuniconverter/onlineuniconverter-php
You can use the OnlineUniConverter Api to see the available options for the various task types.
Creating Import Tasks
use OnlineUniConverter\Models\Import; // init $import = (new Import('import/upload')); $this->OnlineUniConverter->imports()->create($import); // upload $response = $this->OnlineUniConverter->imports()->upload($import, fopen(__DIR__ . '/files/单独.mov', 'r'), 'vid00084source.mov'); var_dump($response); // info $this->OnlineUniConverter->imports()->info($import); var_dump($import);
Creating Convert Tasks
use OnlineUniConverter\Models\Task; // init $task = (new Task('convert'))->set('input', 'jnthak3k-amuk-bj8l-cj7h-nn1yno4jty8i')->set('output_format', 'mp4'); $this->OnlineUniConverter->tasks()->create($task); var_dump($task); // info $this->OnlineUniConverter->tasks()->info($task); var_dump($task);
Creating Export Tasks
use OnlineUniConverter\Models\Common; use OnlineUniConverter\Models\Export; // init $export = (new Export('export/url'))->set('input', '2w2y610m-awgo-bt8q-cq2p-981fu1w1bmr0'); $this->OnlineUniConverter->exports()->create($export); var_dump($export); // info $this->OnlineUniConverter->exports()->info($export); var_dump($export); // download $source = $this->OnlineUniConverter->getHttpTransport()->download($export->getResult()->files[0]->url)->detach(); $dest = tmpfile(); $destPath = stream_get_meta_data($dest)['uri']; stream_copy_to_stream($source, $dest);
You can use the OnlineUniConverter to see the available options for the various task types.
Unit Tests
vendor/bin/phpunit --testsuite unit
Feature Tests
vendor/bin/phpunit --testsuite feature
By default, this runs the integration tests against the Sandbox API with an official OnlineUniConverter account. If you would like to use your own account, you can set your API key using the ONLINEUNICONVERT_API_KEY
enviroment variable. In this case you need to whitelist the following MD5 hashes for Sandbox API (using the OnlineUniConverter dashboard).
684321sdfew31fsdfes6812381e2ewr2 input.mp4
68531sdfsdf684sefsd68465sdfesf28 input.png