code in php for rss feed from any news site
Posted: Mon Jul 20, 2015 4:59 am
Can any one tell me the code in php for rss feed from any news site .....
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Pretty much what was said there. I'd go a step further, and parse it with PHP functions. Since RSS is basically XML, you can use simplexml_load_string to load XML and easily parse it.Christopher wrote:It is just an XML document. Use cURL, fsocketopen, the stream functions or other library to access the URL. Then parse the XML. It is in a standard format.
Code: Select all
<?php
$content = file_get_contents("https://twitrss.me/twitter_user_to_rss/?user=pazuzu156");
$xml = simplexml_load_string($content);
$channel = $xml->channel;
$items = $channel->item;
$string = "<pre>RSS Feed\n\n";
foreach($items as $item)
{
$string .= "Item\n====\n";
$string .= "Title: {$item->title}\n";
$string .= "Description: {$item->description}\n";
$string .= "Published Date: {$item->pubDate}\n";
$string .= "GUID: {$item->guid}\n";
$string .= "Link: {$item->link}\n\n";
}
echo $string . "</pre>";