laravelrsssimplepie

How to use SimplePie laravel package to display rss feed?


I want to display news from the given rss feed url. But I am not getting anything in data section. Below is the code I tried from https://github.com/willvincent/feeds and replaced the url.

public function demo() {
    $feed = Feeds::make('https://timesofindia.indiatimes.com/rssfeeds/296589292.cms);
    $data = array(
      'title'     => $feed->get_title(),
      'permalink' => $feed->get_permalink(),
      'items'     => $feed->get_items(),
    );

    return View::make('feed', $data);
  }

When I print the $feed I am getting the below information.

SimplePie {#1572 ▼
  +data: array:3 [▼
    "type" => 0
    "links" => []
    "items" => []
  ]
  +error: "cURL error 60: SSL certificate problem: unable to get local issuer certificate"
  +sanitize: SimplePie_Sanitize {#1573 ▶}
  +useragent: "SimplePie/1.5.3 (Feed Parser; http://simplepie.org; Allow like Gecko) Build/20200302054845"
  +feed_url: "https://timesofindia.indiatimes.com/rssfeeds/296589292.cms"
  +permanent_url: "https://timesofindia.indiatimes.com/rssfeeds/296589292.cms"
  +file: null
  +raw_data: null
  +timeout: 10
  +curl_options: []
  +force_fsockopen: false
  +force_feed: false
  +cache: true
  +force_cache_fallback: false
  +cache_duration: 3600
  +autodiscovery_cache_duration: 604800
  +cache_location: "D:\Laraveltest\laravelinit_latest_2020_02_17\storage\framework/cache"
  +cache_name_function: "md5"
  +order_by_date: true
  +input_encoding: false
  +autodiscovery: 31
  +registry: SimplePie_Registry {#1574 ▶}
  +max_checked_feeds: 10
  +all_discovered_feeds: []
  +image_handler: ""
  +multifeed_url: []
  +multifeed_objects: []
  +config_settings: null
  +item_limit: 0
  +check_modified: false
  +strip_attributes: array:14 [▶]
  +add_attributes: array:3 [▶]
  +strip_htmltags: array:19 [▶]
  +enable_exceptions: false
}

Please help me out to solve this.


Solution

  • As you see in your output you are getting cURL error 60: SSL certificate problem in your curl

    cURL error 60: SSL certificate problem: unable to get local issuer certificate

    To resolve this if you are using XAMPP server. You can download cacert.pem file from the below link and put it in your under C:\xampp\php\extras\ssl\cacert.pem and add it's path php.ini file

    https://curl.haxx.se/docs/caextract.html

    Put it here

    C:\xampp\php\extras\ssl\cacert.pem
    

    In your php.ini put this line in this section ("c:\xampp\php\php.ini"):

    curl.cainfo = "C:\xampp\php\extras\ssl\cacert.pem"
    

    restart your webserver/apache

    Laracast -> cURL error 60: SSL certificate problem: unable to get local issuer certificate