Skip to content

Instantly share code, notes, and snippets.

@cleverdevil
Created April 12, 2017 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cleverdevil/e3fe357d3c4a84bfc71d2dd4958191c6 to your computer and use it in GitHub Desktop.
Save cleverdevil/e3fe357d3c4a84bfc71d2dd4958191c6 to your computer and use it in GitHub Desktop.
<?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