【问题标题】:How to use SimplePie laravel package to display rss feed?如何使用 SimplePie laravel 包显示 rss 提要?
【发布时间】:2020-03-02 07:54:13
【问题描述】:

我想显示来自给定 rss 提要 url 的新闻。但我在数据部分没有得到任何东西。以下是我从https://github.com/willvincent/feeds 尝试的代码并替换了网址。

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
}

请帮我解决这个问题。

【问题讨论】:

    标签: laravel rss simplepie


    【解决方案1】:

    正如您在输出中看到的那样,您在 curl 中得到 cURL error 60: SSL certificate problem

    cURL 错误 60:SSL 证书问题:无法获取本地颁发者证书

    如果您使用 XAMPP 服务器来解决此问题。您可以从以下链接下载cacert.pem文件并将其放在C:\xampp\php\extras\ssl\cacert.pem下并添加其路径php.ini文件

    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"
    

    重启你的网络服务器/apache

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-11
      • 2011-07-23
      • 1970-01-01
      • 2020-08-25
      • 1970-01-01
      相关资源
      最近更新 更多