mardi 3 octobre 2017

How to get Rss with simplexml_load_string and Laravel

I've been writing a starting page in laravel and vuejs. One part of it is a simple RSS reader. I couldn't get to item section with simplexml_load_string. I can display an only first record or nothing. My controller

public $rssRecords = null; 
public $rssData = null;

public function __construct() {
    $this->rssRecords = $this->get_rss();
}

public function index()
{
    $factorizedRss = $this->rssData;
    return view('rss', compact('factorizedRss'));

}
public function get_rss() {
    $rssData  = file_get_contents('http://ift.tt/2yl2jar');
    $rssData = simplexml_load_string($rssData);
    // $rssRecords = array();
    // foreach ($rssData->item as $record) {
    //     $rssRecords[] = array(
    //         'title' => (string)$record->title,
    //         'description' => (string)$record->description,
    //     );
    // }

    return $rssData;
}

My blade temp:

@foreach ($factorizedRss as $record)
<h1> </h1>  
@endforeach



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire