ShikiryuRSS/params.json

1 line
2.4 KiB
JSON

{"name":"ShikiryuRSS","tagline":"Create and read RSS file in PHP","body":"All documentation @ http://labs.shikiryu.com/SRSS/#_how\r\n\r\n----------------------------------\r\n\r\nHow to make it read RSS?\r\n\r\nFirst, we need to load the RSS :\r\n\r\n $rss = SRSS::read('http://exemple.com/rss.xml');\r\n\r\nEasy, right? Then you can extract general informations :\r\n\r\n echo $rss->title; // will display blog title\r\n\r\nThen, you can take care of articles. You can select a precise article :\r\n\r\n $article1 = $rss->getItem(1); // or $rss->getFirst();\r\n\r\nOr looping them :\r\n\r\n foreach($rss as $article)\r\n {\r\n echo '<a href=\"'.$article->link.'\">'. SRSSTools::formatDate('d/m/y', $item->pubDate).' '.$item->title.'';\r\n }\r\n\r\nIf you like arrays, you can transform the RSS into an array :\r\n\r\n $rssArray = $rss->toArray();\r\n\r\nYou can also save it into your server with :\r\n\r\n $rss->save('/www/rss/rss.xml'); // example\r\n\t\r\n----------------------------------\r\n\r\nHow to make it create RSS?\r\n\r\nFirst, we need to initialize the RSS :\r\n\r\n $rss = SRSS::create();\r\n\r\nEasy, right? Then you can add general informations :\r\n\r\n $rss->title = 'My Awesome Blog';\r\n $rss->link = 'http://shikiryu.com/devblog/';\r\n $rss->description = 'is awesome';\r\n\r\nThose 3 are mandatory to validate your RSS, other options can be added.\r\nThen, you can add articles. Let's imagine $content contains an array from your database.\r\n\r\n foreach($content as $item){\r\n $rssitem= new SRSSItem; // we create an item\r\n $rssitem->title = $item[\"title\"]; // adding title (option)\r\n $rssitem->link = $item['link']; // adding link (option)\r\n $rssitem->pubDate = $item[\"date\"]; // date automatically transformed into RSS format (option)\r\n $rssitem->description = $item[\"text\"]; // adding description (mandatory)\r\n $rss->addItem($rssitem); // we add the item into our RSS\r\n }\r\n\r\nThere are 2 functions to add item.\r\nThe first one will add items in the order you enter them, from top to bottom.\r\n\r\n $rss->addItem($item);\r\n\r\nThe other one does the opposite and add the next item in top of your RSS\r\n\r\n $rss->addItemBefore($item);\r\n\r\n----------------------------------\r\n\r\nContact :\r\nhttp://shikiryu.com/contact\r\n","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."}