Jump to content

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/86119-rss-feeds-in-php/
Share on other sites

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?

 

Link to comment
https://forums.phpfreaks.com/topic/86119-rss-feeds-in-php/#findComment-439808
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.