2017-25 © Pedro Peláez
 

library moovly-php-sdk

The Moovly PHP SDK

image

moovly/moovly-php-sdk

The Moovly PHP SDK

  • Friday, July 27, 2018
  • by nielsvermaut
  • Repository
  • 3 Watchers
  • 0 Stars
  • 71 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 15 Versions
  • 0 % Grown

The README.md

Tests, (*1)

Moovly PHP SDK

This PHP SDK implements the API calls documented in the Moovly API Hub, (*2)

Versioning of this SDK is matched to the API Hub documentation versioning., (*3)

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

The Versions

27/07 2018

dev-master

9999999-dev

The Moovly PHP SDK

  Sources   Download

The Requires

 

The Development Requires

by Niels

video automation moovly

27/07 2018

1.1.5

1.1.5.0

The Moovly PHP SDK

  Sources   Download

The Requires

 

The Development Requires

by Niels

video automation moovly

27/07 2018

dev-release/5.6

dev-release/5.6

The Moovly PHP SDK

  Sources   Download

The Requires

 

The Development Requires

by Niels

video automation moovly

17/07 2018

0.56.1

0.56.1.0

The Moovly PHP SDK

  Sources   Download

The Requires

 

The Development Requires

by Niels

video automation moovly

17/07 2018

1.1.4

1.1.4.0

The Moovly PHP SDK

  Sources   Download

The Requires

 

The Development Requires

by Niels

video automation moovly

21/06 2018

1.1.3

1.1.3.0

The Moovly PHP SDK

  Sources   Download

The Requires

 

The Development Requires

by Niels

video automation moovly

21/06 2018

1.1.2

1.1.2.0

The Moovly PHP SDK

  Sources   Download

The Requires

 

The Development Requires

by Niels

video automation moovly

21/06 2018

1.1.1

1.1.1.0

The Moovly PHP SDK

  Sources   Download

The Requires

 

The Development Requires

by Niels

video automation moovly

20/06 2018

1.1.0

1.1.0.0

The Moovly PHP SDK

  Sources   Download

The Requires

 

The Development Requires

by Niels

video automation moovly

19/06 2018

1.0.5

1.0.5.0

The Moovly PHP SDK

  Sources   Download

The Requires

 

The Development Requires

by Niels

video automation moovly

19/06 2018

1.0.4

1.0.4.0

The Moovly PHP SDK

  Sources   Download

The Requires

 

The Development Requires

by Niels

video automation moovly

19/06 2018

1.0.3

1.0.3.0

The Moovly PHP SDK

  Sources   Download

The Requires

 

The Development Requires

by Niels

video automation moovly

19/06 2018

1.0.2

1.0.2.0

The Moovly PHP SDK

  Sources   Download

The Requires

 

The Development Requires

by Niels

video automation moovly

15/06 2018

1.0.1

1.0.1.0

The Moovly PHP SDK

  Sources   Download

The Requires

 

The Development Requires

by Niels

video automation moovly

18/05 2018

1.0.0

1.0.0.0

The Moovly PHP SDK

  Sources   Download

The Requires

 

The Development Requires

by Niels

video automation moovly