Skip to content

Instantly share code, notes, and snippets.

@cleverdevil
Created Apr 12, 2017
Embed
What would you like to do?
<?php
namespace IdnoPlugins\Watching\Pages {
use Idno\Common\ContentType;
class Endpoint extends \Idno\Common\Page
{
function post()
{
//$payload = $_REQUEST['payload'];
$payload = $this->getInput('payload');
$hook = json_decode($payload);
if ($hook->event == 'media.play')
{
$title = '';
$watchType = '';
$player = $hook->Player->title;
$body = $hook->Metadata->summary;
if ($hook->Metadata->type == 'movie')
{
$watchType = 'movie';
$title = $hook->Metadata->title;
} else if ($hook->Metadata->type == 'episode')
{
$watchType = 'tv';
$title = $hook->Metadata->grandParentTitle . " " . $hook->Metadata->parentTitle . " " . $hook->Metadata->title;
}
$this->setInput('body', $body);
$this->setInput('title', $title);
$this->setInput('watchType', $watchType);
$this->setInput('player', $player);
$this->setInput('access', 'PRIVATE');
$_FILES['photo'] = $_FILES['thumb'];
$contentType = ContentType::getRegisteredForIndieWebPostType('watching');
$entity = $contentType->createEntity();
$entity->saveDataFromInput();
}
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment