SimplePie 不解析 RSS 提要
SimplePie Not Parsing RSS Feed
我已经使用 SimplePie 大约 4 年了 w/Curl...它在 2-6-17 之前一直运行良好。
在过去的 12 多个小时里,我一直在努力缩小它不解析任何 craigslists 列表供稿的原因。我已经尝试过任何可能的场景。我确实得到了一个 200 return 的数据,但它包含了一个错误。
is invalid XML, likely due to invalid characters. XML error: Not well-formed (invalid token) at line 1, column 1
奇怪的是,它与 fopensocket 一起使用没有问题。
这里是我的一些设置:
Ubuntu 14.04
Apache/Ngnix
PHP 5.6
Host: VPS DigitalOcean
SimplePie v-1.4.3
$rss = new SimplePie();
$rss->set_feed_url('http://detroit.craigslist.org/search/apa?availabilityMode=0&bedrooms=3&format=rss&min_price=800');
$rss->useragent= 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.7) Gecko/20070914 Firefox/2.1.0.7';
$rss->get_item_quantity( 10 );
$rss->force_feed(true);
$rss->force_fsockopen(false);
$rss->set_input_encoding('UTF-8');
$rss->set_output_encoding('UTF-8');
$rss->init();
$rss->handle_content_type();
这是 header 的 return:
HTTP/1.1 200 OK
Cache-Control: max-age=900, public Last-Modified: Mon, 13 Feb 2017 18:24:12 GMT Date: Mon, 13 Feb 2017 18:24:12 GMT Content-Encoding: gzip Vary: Accept-Encoding Content-Length: 5991 Content-Type: application/rss+xml; charset=utf-8 X-Frame-Options: SAMEORIGIN Server: Apache Expires: Mon, 13 Feb 2017 18:39:12 GMT
我已经完成了 RSS 验证,没有任何重大错误。
此外,在全新的 server/same 设置上进行了尝试,得到了相同的结果。
他们在演示站点 simplepie 上工作。org/demo...所以我认为这与我的服务器设置有关。
如有任何帮助,我们将不胜感激!
找到了!现在适用于较旧的代理
我在 FILE.php
的第 158 行添加了这个
// cURL automatically handles Proxy rewrites, remove the "HTTP/1.0 200 Connection established" string
$this->headers = explode("\r\n\r\n", $this->headers, $info['redirect_count'] + 1);
$this->headers = array_pop($this->headers);//$this->headers[0];//
if (false !== stripos($this->headers, "HTTP/1.0 200 Connection established\r\n\r\n")) { $this->headers = str_ireplace("HTTP/1.0 200 Connection established\r\n\r\n", '', $this->headers);}
我已经使用 SimplePie 大约 4 年了 w/Curl...它在 2-6-17 之前一直运行良好。
在过去的 12 多个小时里,我一直在努力缩小它不解析任何 craigslists 列表供稿的原因。我已经尝试过任何可能的场景。我确实得到了一个 200 return 的数据,但它包含了一个错误。
is invalid XML, likely due to invalid characters. XML error: Not well-formed (invalid token) at line 1, column 1
奇怪的是,它与 fopensocket 一起使用没有问题。
这里是我的一些设置:
Ubuntu 14.04
Apache/Ngnix
PHP 5.6
Host: VPS DigitalOcean
SimplePie v-1.4.3
$rss = new SimplePie();
$rss->set_feed_url('http://detroit.craigslist.org/search/apa?availabilityMode=0&bedrooms=3&format=rss&min_price=800');
$rss->useragent= 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.7) Gecko/20070914 Firefox/2.1.0.7';
$rss->get_item_quantity( 10 );
$rss->force_feed(true);
$rss->force_fsockopen(false);
$rss->set_input_encoding('UTF-8');
$rss->set_output_encoding('UTF-8');
$rss->init();
$rss->handle_content_type();
这是 header 的 return:
HTTP/1.1 200 OK
Cache-Control: max-age=900, public Last-Modified: Mon, 13 Feb 2017 18:24:12 GMT Date: Mon, 13 Feb 2017 18:24:12 GMT Content-Encoding: gzip Vary: Accept-Encoding Content-Length: 5991 Content-Type: application/rss+xml; charset=utf-8 X-Frame-Options: SAMEORIGIN Server: Apache Expires: Mon, 13 Feb 2017 18:39:12 GMT
我已经完成了 RSS 验证,没有任何重大错误。
此外,在全新的 server/same 设置上进行了尝试,得到了相同的结果。
他们在演示站点 simplepie 上工作。org/demo...所以我认为这与我的服务器设置有关。
如有任何帮助,我们将不胜感激!
找到了!现在适用于较旧的代理
我在 FILE.php
的第 158 行添加了这个 // cURL automatically handles Proxy rewrites, remove the "HTTP/1.0 200 Connection established" string
$this->headers = explode("\r\n\r\n", $this->headers, $info['redirect_count'] + 1);
$this->headers = array_pop($this->headers);//$this->headers[0];//
if (false !== stripos($this->headers, "HTTP/1.0 200 Connection established\r\n\r\n")) { $this->headers = str_ireplace("HTTP/1.0 200 Connection established\r\n\r\n", '', $this->headers);}