daveh33 Posted January 15, 2008 Share Posted January 15, 2008 I have a RSS feed which I want to use php to display the information correctly e.g make url hyperlinks below is the current output - how can I do this? <rss version="2.0"> − <channel> <title>Mobile Search API</title> − <link> /search/api/v1/Entry.aspx?uid=11&st=free%20chat&count=10&ua=MOT-V500 </link> − <description> Monetised mobile search results from API parameters </description> <openSearch:totalResults>11</openSearch:totalResults> <openSearch:startIndex>1</openSearch:startIndex> <openSearch:itemsPerPage>10</openSearch:itemsPerPage> − <item> <title>Chat - Free Chat Community</title> − <link> http://www.mcproton.com/Search/API/v1/Click.aspx?mct=f28a17hd09203ghe&mca=ChooseAd&mci=-1g245 </link> − <description> For More Cool Stuff - Free Chat - Chat with people around the world - GO CHAT... </description> <mc:resultType>B</mc:resultType> </item> − <item> Quote Link to comment https://forums.phpfreaks.com/topic/86119-rss-feeds-in-php/ Share on other sites More sharing options...
daveh33 Posted January 15, 2008 Author Share Posted January 15, 2008 Never used RSS before is there a simple way to get the <title> </title> ? & same with description & link Quote Link to comment https://forums.phpfreaks.com/topic/86119-rss-feeds-in-php/#findComment-439777 Share on other sites More sharing options...
tinker Posted January 15, 2008 Share Posted January 15, 2008 http://www.phpfreaks.com/quickcode_cats/24/RSS-&-Syndication.php Quote Link to comment https://forums.phpfreaks.com/topic/86119-rss-feeds-in-php/#findComment-439800 Share on other sites More sharing options...
daveh33 Posted January 15, 2008 Author Share Posted January 15, 2008 many thanks - I have used that tutorial to write the below code - but it just displays a blank screen <?php $url = "xxx"; function RSSreader($url) { $rssstring = file_get_contents($url); preg_match_all("#<title>(.*?)</title>#s",$rssstring,$titel); preg_match_all("#<item>(.*?)</item>#s",$rssstring,$items); $n=count($items[0]); for($i=0;$i<$n;$i++) { $rsstemp= $items[0][$i]; preg_match_all("#<title>(.*?)</title>#s",$rsstemp,$titles); $title[$i]= $titles[1][0]; preg_match_all("#<pubDate>(.*?)</pubDate>#s",$rsstemp,$dates); $date[$i]= $dates[1][0]; preg_match_all("#<link>(.*?)</link>#s",$rsstemp,$links); $link[$i]= $links[1][0]; preg_match_all("#<description>(.*?)</description>#s",$rsstemp,$links); $description[$i]= $description[1][0]; } echo "<h2>".$title[1][0]."</h2>"; for($i=0;$i<$n;$i++) { $timestamp=strtotime($date[$i]); $datum=date('d-m-Y H\hi', $timestamp); if(!empty($title[$i])) echo $datum."\t\t\t <a href=".$link[$i]." target=\"_blank\">".$title[$i]."</a><br>$description[$i]"; } } ?> The RSS feed has:- item title link description Can anyone see where I am going wrong? Quote Link to comment https://forums.phpfreaks.com/topic/86119-rss-feeds-in-php/#findComment-439808 Share on other sites More sharing options...
nikefido Posted January 15, 2008 Share Posted January 15, 2008 you hid the $url variable from us, right? it isn't actually $url = "xxx"; in your own code? Quote Link to comment https://forums.phpfreaks.com/topic/86119-rss-feeds-in-php/#findComment-439949 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.