moovly / moovly-php-sdk
The Moovly PHP SDK
Installs: 2 578
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 12
Forks: 0
Open Issues: 0
Requires
- php: ^7.1|^8.0
- guzzlehttp/guzzle: ^6.3|^7.0
- nicmart/string-template: ^0.1.1
Requires (Dev)
- phpspec/phpspec: ^5.1 || ^7.0
- sebastian/comparator: ^1.2.4 || ^4.0
- dev-master
- 2.2.1
- 2.2.0
- 2.1.0
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.3.7
- 1.3.6
- 1.3.5
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.7
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 0.56.2
- 0.56.1
- dev-feature/fix-tests
- dev-feature/add-metada-job
- dev-feature/metadata-ob
- dev-support-project-stage
- dev-feature/template-quality
This package is auto-updated.
Last update: 2024-12-12 16:25:43 UTC
README
Moovly PHP SDK
This PHP SDK implements the API calls documented in the Moovly API Hub
Versioning of this SDK is matched to the API Hub documentation versioning.
Usage
<?php # Use composer require __DIR__ . '/vendor/autoload.php'; use Moovly\SDK\Client\APIClient; use Moovly\SDK\Service\MoovlyService; use Moovly\SDK\Model\Project; use Moovly\SDK\Model\User; use Moovly\SDK\Model\Template; use Moovly\SDK\Model\Variable; use Moovly\SDK\Model\Value; use Moovly\SDK\Model\Job; use Moovly\SDK\Factory\ValueFactory; use Moovly\SDK\Factory\JobFactory; use Moovly\SDK\Model\MoovlyObject; use Moovly\SDK\Model\Library; # Visit https://developer.moovly.com/docs/authentication for a token $token = 'YOUR MOOVLY TOKEN'; $client = new APIClient(); $service = new MoovlyService($client, $token); /** @var Project $project */ $project = $service->getProject('project-id'); /** @var Project[] $projects */ $projects = $service->getProjects(); /** @var Template[] $template */ $filters = []; $templates = $service->getTemplates($filters); /** @var Template $template */ $template = $service->createTemplate($project); /** @var Template $template */ $template = $service->getTemplate('template-id'); /** @var Library $library */ $library = $service->getPersonalLibraryForUser(); $image = new \SplFileInfo('image.jpeg'); /** @var MoovlyObject $imageObject */ $imageObject = $service->uploadAsset($image, $library); $video = new \SplFileInfo('video.mp4'); /** @var MoovlyObject $videoObject */ $videoObject = $service->uploadAsset($video, $library); do { $object = $service->getObject($videoObject->getId()); } while (!$object->getStatus()); echo $videoObject->getId(); $templateVariables = []; foreach ($template->getVariables() as $key => $variable) { if ($variable->getType() === Variable::TYPE_TEXT) { $templateVariables[$variable->getId()] = 'Value ' . $key; } if ($variable->getType() === Variable::TYPE_IMAGE) { $templateVariables[$variable->getId()] = $imageObject->getId(); } if ($variable->getType() === Variable::TYPE_IMAGE) { $templateVariables[$variable->getId()] = $videoObject->getId(); } } /** @var Value $value */ $value = ValueFactory::create('my-video-id-1', 'My Video Title 1', $templateVariables); /** @var Job $job */ $job = JobFactory::create([$value]); /** @var Job $job */ $job = $service->createJob($job); do { echo 'Polling job until finished'; $job = $service->getJob($job->getId()); sleep(60); } while ($job->getStatus() === 'finished' || $job->getStatus() === 'error'); echo 'Polling job until finished'; $urls = array_map(function (Value $value) { return $value->getUrl(); }, $job->getValues()); foreach ($urls as $url) { echo 'Video url: ' . $url; } /** @var User $user */ $user = $service->getCurrentUser(); /** @var Job[] $jobs */ $jobs = $service->getJobsByUser($user); /** @var Job[] $jobs */ $jobs = $service->getJobsByTemplate($template);
Running tests
$ vendor/bin/phpspec run