jaysalvat/medium-json-parser

Php parser for the Medium JSON API.

1.1.1 2017-01-23 18:35 UTC

This package is not auto-updated.

Last update: 2024-04-22 11:53:18 UTC


README

Latest Stable Version License

This is a PHP parser for the Medium Json API.

Installation:

Create a composer.json file with:

{
   "require": {
       "jaysalvat/medium-json-parser": "~1.0"
   }
}

Run Composer to install MediumJsonParser.

$ curl -sS https://getcomposer.org/installer | php
$ composer.phar install

Example:

$url = 'https://medium.com/@jaysalvat/my-title-99dcb55001b6';

$parser = new MediumJsonParser\Parser($url);

// Path to the iFrame proxy, see below
$parser->iframeProxyPath = 'iframe.php';

// Image compression
$parser->imageQuality = 80;

// Image max size
$parser->imageWidth = 2000;

$html = $parser->html([
    // Skip/keep the title and subtitle
    'skip_header'  => false,

    // HTML or Array of HTML
    'return_array' => false
]);

echo $html;

iFrame Proxy

To avoid CORS issues with iFrame, create a iframe.php proxy.

readfile('http://medium.com/media/' . $_GET['resource_id'] . '?postId=' . $_GET['post_id'] . '"');