PHP parser for the Medium Json API.
PHP CSS
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
example
src/MediumJsonParser
.gitignore
README.md
composer.json
composer.lock

README.md

Medium Json Parser

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'] . '"');