PHPackages                             qaamgo/onlineconvert-api-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. qaamgo/onlineconvert-api-sdk

ActiveLibrary[HTTP &amp; Networking](/categories/http)

qaamgo/onlineconvert-api-sdk
============================

Sdk for using the Online Convert Api version 2

3.1.8(1y ago)3975.4k—3.7%23Apache-2.0PHPPHP ^7.1|^8.0CI failing

Since Jul 9Pushed 1y ago8 watchersCompare

[ Source](https://github.com/onlineconvert/onlineconvert-api-sdk-php)[ Packagist](https://packagist.org/packages/qaamgo/onlineconvert-api-sdk)[ RSS](/packages/qaamgo-onlineconvert-api-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (46)Used By (0)

Online Convert API version 2 PHP SDK v 3
========================================

[](#online-convert-api-version-2-php-sdk-v-3)

This SDK provides a code base to interact with the API version 2 of [Online-Convert.com](http://www.online-convert.com/)

[![Tests](https://github.com/onlineconvert/onlineconvert-api-sdk-php/actions/workflows/ci.yml/badge.svg)](https://github.com/onlineconvert/onlineconvert-api-sdk-php/actions/workflows/ci.yml)

Installation
------------

[](#installation)

The recommended way to install is through [Composer](https://getcomposer.org/).

```
composer require qaamgo/onlineconvert-api-sdk
```

Getting started
---------------

[](#getting-started)

#### Configuration

[](#configuration)

```
require 'vendor/autoload.php';

$config = new \OnlineConvert\Configuration();
$config->setApiKey('main', 'HERE YOUR API KEY');
$client = new \OnlineConvert\Client\OnlineConvertClient($config, 'main');
$syncApi = new \OnlineConvert\Api($client);
$asyncApi = new \OnlineConvert\Api($client, true);
```

#### Sending a full job

[](#sending-a-full-job)

```
$syncJob = [
	'input' => [
	    [
		'type' => \OnlineConvert\Endpoint\InputEndpoint::INPUT_TYPE_UPLOAD,
		'source' => '~/example.png'
	    ],
	    [
		'type' => \OnlineConvert\Endpoint\InputEndpoint::INPUT_TYPE_REMOTE,
		'source' => 'http://cdn.online-convert.com/images/logo-top.png'
	    ]
	],
	'conversion' => [
	    [
		'target' => 'png'
	    ],
	    [
		'target' => 'mp4'
	    ]
	]
];

$asyncJob = [
	'input' => [
	    [
		'type' => \OnlineConvert\Endpoint\InputEndpoint::INPUT_TYPE_UPLOAD,
		'source' => '~/example.png'	            ],
	    [
		'type' => \OnlineConvert\Endpoint\InputEndpoint::INPUT_TYPE_REMOTE,
		'source' => 'http://cdn.online-convert.com/images/logo-top.png'
	    ]
	],
	'conversion' => [
	    [
		'target' => 'png'
	    ],
	    [
		'target' => 'mp4'
	    ]
	],
	'callback' => 'http://alert.me/when/job/is/finished'
];

$syncJob = $syncApi->postFullJob($syncJob)->getJobCreated();
$asyncJob = $asyncApi->postFullJob($asyncJob)->getJobCreated();

var_dump($syncJob, $asyncJob);
```

### Sending a job with a gdrive\_picker input

[](#sending-a-job-with-a-gdrive_picker-input)

#### What is google drive picker

[](#what-is-google-drive-picker)

Google drive picker allows you to access files stored in your google drive account.

You can find information about it in [the official page](https://developers.google.com/picker/)

**Meaning of each field**:

- type
    - Specifies that we want to use the google drive picker input
- source
    - This must contain the **FILE ID** given back by the google drive picker
- credentials
    - This must be an array containing the credentials for the selected file
    - At the moment you only need to pass the **"token"** field inside it
        - The **"token"** field is returned by the google drive picker when a file is selected
- content\_type
    - This field is mandatory when you select a [Google Document](https://developers.google.com/drive/v3/web/mime-types)
    - You can leave this field empty if you are selecting any other kind of file
        - EG: pdf, png, zip...
- filename
    - This is the file name of the google drive picker file
    - If this field is not sent the file will be downloaded with the name `output.`

```
$job = [
    'input' => [
        [
            'type' => \OnlineConvert\Endpoint\InputEndpoint::INPUT_TYPE_GDRIVE_PICKER,
            'source' => '',
            'credentials' => [
                'token' => ''
            ],
            'content_type' => '',
            'filename' => ''
        ]
    ],
    'conversion' => [
        [
            'target' => 'png'
        ]
    ]
];

```

After this just follow the previous examples on how to effectively send the job to the API.

#### Sending a job using Cloud storage providers

[](#sending-a-job-using-cloud-storage-providers)

The following is an example to send a job where we want to convert a file that we have stored in our Amazon S3 storage.

If you want to know more please check our cloud storage **[API documentation](http://apiv2.online-convert.com/#cloud_storage)**

```
$job = [
    'input' => [
        [
            'type' => \OnlineConvert\Endpoint\InputEndpoint::INPUT_TYPE_CLOUD,
            'source' => 'amazons3',
            'parameters' => [
                'bucket' => 'your.bucket.name',
                'file' => 'the complete path to the file',
            ],
            'credentials' => [
                'accesskeyid' => 'your access key id',
                'secretaccesskey' => 'your secret access key',
            ]
        ]
    ],
    'conversion' => [
        [
            'target' => 'png'
        ]
    ]
];

```

After this just follow the previous examples on how to effectively send the job to the API.

#### Downloading the Converted Files

[](#downloading-the-converted-files)

You can download the converted files using the following code snippet:

```
require_once __DIR__ . '/vendor/autoload.php';

$config = new \OnlineConvert\Configuration();
$config->setApiKey('main', 'PUT YOUR API KEY HERE');

// Remember to specify your own downloads folder.
$config->downloadFolder = __DIR__ . '/downloads';

$client = new \OnlineConvert\Client\OnlineConvertClient($config, 'main');
$syncApi = new \OnlineConvert\Api($client);
$outputEndpoint = $syncApi->getOutputEndpoint();

$syncJob = [
    'input' => [
        [
            'type' => \OnlineConvert\Endpoint\InputEndpoint::INPUT_TYPE_REMOTE,
            'source' => 'PUT URL HERE'
        ]
    ],
    'conversion' => [
        [
            'target' => 'jpg'
        ]
    ]
];

$job = $syncApi->postFullJob($syncJob)->getJobCreated();

// You will find the file/s in the downloads folder
$outputEndpoint->downloadOutputs($job);

```

Advanced usage
--------------

[](#advanced-usage)

> The class **\\OnlineConvert\\Api::class** has some shortcut methods that links it to the endpoints classes *(EG: **\\OnlineConvert\\Api::postFullJob()**)*, but from the class you can call the real endpoint and their methods.

> Also, you can create endpoint classes one by one if you like. For this, check **\\OnlineConvert\\Endpoint\\Abstracted::\_construct()**

> **IMPORTANT:** The class **\\OnlineConvert\\Endpoint\\JobsEndpoint** can be used to send both synchronous and asynchronuos jobs; check **\\OnlineConvert\\Endpoint\\JobsEndpoint::setAsync()**

> You can also set up different headers into the client, and do some process using the token of a job.

```
    $config = new \OnlineConvert\Configuration();
    $client = new \OnlineConvert\Client\OnlineConvertClient($config);
    $syncApi = new \OnlineConvert\Api($client);

    $ep = $syncApi->getJobsEndpoint();

    //Option 1
    $ep->getClient()->setHeader(\OnlineConvert\Client\Interfaced::HEADER_OC_API_KEY, 'YOUR API KEY');

    //Option 2
    //$client->setHeader(\OnlineConvert\Client\Interfaced::HEADER_OC_API_KEY, 'YOUR API KEY');
    //$ep->setClient($client);

    $job = $ep->postJob([]);

    $ip = $syncApi->getInputEndpoint();

    //WORK WITH TOKENS
    //OPTION 1
    $input = $ip->setUserToken($a['token'])->postJobInputRemote('http://www.online-convert.com/', $a['id']);

    //Option 2 (Apply also the previous options to set a header)
    //$ip->getClient()->setHeader(\OnlineConvert\Client\Interfaced::HEADER_OC_JOB_TOKEN, $a['token']);
    //$b = $ip->postJobInputRemote('http://www.online-convert.com/', $a['id']);

    var_dump($job, $input);

```

#### Manage exceptions

[](#manage-exceptions)

> If you catch **\\OnlineConvert\\Exception\\OnlineConvertSdkException::class**, you automatically catch all exception in this SDK

#### Getting url to upload file

[](#getting-url-to-upload-file)

- Send a job request
- Take the following keys from a job: **server** and **id**. You can use **\\OnlineConvert\\Api** or **\\OnlineConvert\\Endpoint\\JobsEndpoint** to get the job information. You will get something like:

```
	[
	    [id] => 00000000-0000-0000-0000-000000000000
	    [token] => some_token_here
		    ...
	    [server] => http://www9.online-convert.com/dl
	    ...
	]

```

- Now with this information you can make this call:

```
\OnlineConvert\Client\OnlineConvertClient->generateUrl(\OnlineConvert\Endpoint\Resources::URL_POST_FILE, ['server' => $server, 'job_id' => $jobId])
```

- Also these token can be useful for some operations that you might want to share with your users

#### Uploading files directly to the [Online-Convert.com](http://www.online-convert.com/) servers via AJAX

[](#uploading-files-directly-to-the-online-convertcom-servers-via-ajax)

> **Real life case:** I want to send our user files directly to the API, because sending them to my app first and then to the API costs too much time.

> **Considerations:** Normally, this will save us process time, space on the hard drive and improve user experience, but it's advised to have a fallback alternative that works without using JS.

> The following example is using **JQuery**.

> **IMPORTANT:** The upload **MUST** be done one by one. Thus, you need one form per file.

#### HTML CODE

[](#html-code)

```

```

#### JS

[](#js)

```
$(document).ready(function () {
        $('#postFile').submit(function (event) {
            event.preventDefault();

            var formData = new FormData($(this)[0]);

            $.ajax({
                url: 'URL_GENERATED_TO_UPLOAD_FILE',
                type: 'POST',
                data: formData,
                async: false,
                cache: false,
                processData: false,
                contentType: false,
                mimeType: 'multipart/form-data',
                headers: {
                    'x-oc-token': 'JOB_TOKEN_HERE',
                    'cache-control': 'no-cache'
                },
                success: function () {
                    window.alert('Success');
                },
                error: function () {
                    window.alert('Error');
                }
            });
        });
    });
```

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity42

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 77.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~75 days

Recently: every ~182 days

Total

44

Last Release

722d ago

Major Versions

1.3 → 2.02016-08-26

2.8.8 → 3.02020-06-16

PHP version history (4 changes)1.0PHP &gt;=5.3.3

2.0PHP ^5.6|^7.0

3.0PHP ^7.1

3.1.2PHP ^7.1|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/09d5bc1966c03547b57534d0c815dfa670a582af8ccfe4279560f8a9b60e7e7c?d=identicon)[onlineconvert](/maintainers/onlineconvert)

---

Top Contributors

[![online-convert](https://avatars.githubusercontent.com/u/23310814?v=4)](https://github.com/online-convert "online-convert (61 commits)")[![qaamgo-luca](https://avatars.githubusercontent.com/u/222397712?v=4)](https://github.com/qaamgo-luca "qaamgo-luca (9 commits)")[![andrescevp](https://avatars.githubusercontent.com/u/10025841?v=4)](https://github.com/andrescevp "andrescevp (3 commits)")[![ashishranpara](https://avatars.githubusercontent.com/u/2619547?v=4)](https://github.com/ashishranpara "ashishranpara (2 commits)")[![lombartec](https://avatars.githubusercontent.com/u/3073746?v=4)](https://github.com/lombartec "lombartec (1 commits)")[![borjaeu](https://avatars.githubusercontent.com/u/1971162?v=4)](https://github.com/borjaeu "borjaeu (1 commits)")[![qaamgo-christian](https://avatars.githubusercontent.com/u/131861657?v=4)](https://github.com/qaamgo-christian "qaamgo-christian (1 commits)")[![srebb](https://avatars.githubusercontent.com/u/17408051?v=4)](https://github.com/srebb "srebb (1 commits)")

---

Tags

phpapisdkrestconvertfilesqaamgoonline-convert

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/qaamgo-onlineconvert-api-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/qaamgo-onlineconvert-api-sdk/health.svg)](https://phpackages.com/packages/qaamgo-onlineconvert-api-sdk)
```

###  Alternatives

[xeroapi/xero-php-oauth2

Xero official PHP SDK for oAuth2 generated with OpenAPI spec 3

1054.3M14](/packages/xeroapi-xero-php-oauth2)[onesignal/onesignal-php-api

A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com

34170.2k2](/packages/onesignal-onesignal-php-api)[zenditplatform/zendit-php-sdk

PHP client for Zendit API

1204.3k](/packages/zenditplatform-zendit-php-sdk)[huaweicloud/huaweicloud-sdk-php

Huawei Cloud SDK for PHP

1829.2k2](/packages/huaweicloud-huaweicloud-sdk-php)[ory/hydra-client-php

Documentation for all of Ory Hydra's APIs.

1710.8k](/packages/ory-hydra-client-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
