Peter Stuifzand Notes on software, small tools, and the open web.
11:24

endpoint.php

<?php
if ($_GET['action'] == 'channels') {
    $channels = array(
        array('uid' => 'notifications', 'name' => 'Notifications'),
        array('uid' => 'home', 'name' => 'Home'),
    );
    header('Content-Type: application/json');
    echo json_encode(array('channels' => $channels));
}
elseif ($_GET['action'] == 'timeline') {
    $uid = $_GET['channel'];
    $items = array();
    if ($uid == 'notifications') {
        $items[] = array(
            'type' => 'entry',
            'name' => 'Notification',
            'content' => array(
                'text' => 'simple text version',
                'html' => 'simple <b>HTML</b> version',
            ),
            'url' => 'https://example.com/1',
            'published' => '2018-07-22T13:11:00+02:00',
            '_id' => '1',
            '_read'=> false,
        );
    } elseif ($uid == 'home') {
        // add items to $items array ...
    }
    header('Content-Type: application/json');
    echo json_encode(array('items' => $items, 'paging'=>array()));
}