qrss
1.0.0
캐시 옵션을 사용하여 RSS 피드를 json으로 구문 분석하는 API 클래스입니다.
qrss
클래스를 잡고 PHP 파일에서 require를 사용하십시오.
require ' src/qrss.php ' ;
// To fetch an RSS feed as json use
( new qrss ( ' https://news.google.com/?output=rss ' ))-> json ();
// For fresh copy you can use fresh() which will ignore cache
( new qrss ( ' https://news.google.com/?output=rss ' ))-> fresh ()-> json ()
// Get the feed ignoring validation adding novalidate()
( new qrss ( ' https://en.blog.wordpress.com/feed/ ' ))-> novalidate ()-> json ();
// There is also an option to get data in plain text using text() instead of json()
( new qrss ( ' https://news.google.com/?output=rss ' ))-> text ();
구문 분석 메서드를 확장하여 출력을 사용자 지정할 수도 있습니다.
class Myqrss extends qrss {
protected function parse ( $ xml )
{
// you have all the xml elements as SimpleXMLElement object
// parse it however you want, return the array from this
return [
' title ' => ( string ) $ xml -> channel -> title
];
}
}
( new My qrss ( ' https://news.google.com/?output=rss ' ))-> json ();