Show Menu

What is "Live Content"?

Live content is content that you host on your own server. Because it's on your own server, you can change it as often as you like. You can even update it automatically, with PHP or a similar programming language. That's why we call it "live".

You can see all live content on Cheatography here.

What it is useful for?

Any content can be live content. However, it's most useful when you use it to update a content block which changes regularly. For example, live content would be especially useful for live statistics, up-to-the-minute sports results and tables, stock and share prices, TV schedules and even traffic and weather reports.

How does it work?

You host a file on a server you control, containing the content for your content block (in JSON-encoded format). You then plug the URL of this content block into Cheatography. Select "Live Content" as your content block type, and you will be prompted to enter the URL of your content.

The Cheatography system will then begin collecting the file. It will normally only collect the file around once an hour, although if you edit the file it will collect a fresh copy as soon as it can.

The format of the file, and sample code, are on the right.

Live Content File Format

  • "Live Content" files should only contain a JSON-encoded array.
  • Each element of the array should represent a single row of the content block.
  • Each element of the array is, itself, an array of the columns in that row.

Example Code

Sample code, including full scripts, is available at GitHub.

To produce a simple, two column content block with headers:

<?php
    $capitals = array(
        array('**Country**', '**Capital**'),
        array('UK', 'London'),
        array('France', 'Paris'),
        array('Italy', 'Rome'),
        array('Spain', 'Madrid')
    );
    echo json_encode($capitals);

The above generates an array and encodes it to JSON:

[["**Country**","**Capital**"],["UK","London"],["France","Paris"],["Italy","Rome"],["Spain","Madrid"]]