RSS to JSON API : PHP example


<?php
    $rss_url = 'https://news.ycombinator.com/rss';
    $api_endpoint = 'https://api.rss2json.com/v1/api.json?rss_url=';
    $data = json_decode( file_get_contents($api_endpoint . urlencode($rss_url)) , true );

    if($data['status'] == 'ok'){
        echo "====== {$data['feed']['title']} ======\n";

        foreach ($data['items'] as $item) {
            echo "{$item['title']}\n";
        }
    }