-
-
Save cleverdevil/e3fe357d3c4a84bfc71d2dd4958191c6 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 | |
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