Forked from m1ch3lp3r3z/gist:3c6ba23d5cee88cf4321
Last active
August 29, 2015 14:06
-
-
Save juliomenendez/5befb65dab8d5d1ffabe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('APP_ROOT', realpath(dirname(__FILE__)) . '/'); | |
require APP_ROOT . 'vendor/autoload.php'; | |
use Mr\Api\Service; | |
$serv = new Service('xxxxxx', 'xxxxxxxxxxxx'); | |
$channels = $serv->getChannels(); | |
print "Channels count is " . count($channels) . "\n"; | |
print "First channel name in the list is: '" . $channels[0]->name . "'\n"; | |
$channel = $serv->createChannel(array('name' => 'Channel test from php client')); | |
$channel->save(); | |
print "New channel ID is: " . $channel->id . "\n"; | |
$channels = $serv->getChannels(array('name__contains' => 'php', 'id__gt' => 1)); | |
print "Channels that contains `php` in name field and id greater than 1: " . count($channels) . "\n"; | |
$medias = $serv->getMedias(); | |
print "Medias count is " . count($medias) . "\n"; | |
print "First media name in the list is: '" . $medias[0]->title . "'\n"; | |
$media = $serv->createVODMedia(array( | |
'title' => 'Testing php client', | |
'file' => 'http://techslides.com/demos/sample-videos/small.mp4', | |
// Assigning channel to media in creation | |
'channels' => array($channel->id) | |
)); | |
$media->save(); | |
print "New media ID is: " . $media->id . ', in status: ' . $media->status . "\n"; | |
$medias = $serv->getMedias(array('title__contains' => 'php', 'channel__name__contains' => 'test')); | |
print "Medias that contains `php` in title field and that has at least one channel that contains in the name the word `test`: " . count($medias) . "\n"; | |
// Reload media to check channels | |
$media = $serv->getMedia($media->id); | |
print "Media new channel name is: '" . $media->channels[0]->name . "'\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment