如何使用SimplePie laravel包显示rss feed?

How to use SimplePie laravel package to display rss feed?

我想显示来自给定 RSS 提要的新闻 url。但我在数据部分没有得到任何东西。下面是我从 https://github.com/willvincent/feeds 尝试并替换 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);
  }

当我打印 $feed 时,我得到以下信息。

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
}

请帮我解决这个问题。

正如您在输出中看到的那样,您在 curl

中得到了 cURL error 60: SSL certificate problem

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

如果您使用的是 XAMPP 服务器,请解决此问题。您可以从下面 link 下载 cacert.pem 文件并将其放在 C:\xampp\php\extras\ssl\cacert.pem 下并添加它的路径 php.ini file

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

放在这里

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

在您的 php.ini 中将此行放入此部分 ("c:\xampp\php\php.ini"):

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

重启你的webserver/apache

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