Forums

RSS Feed Integration to HTML (3 posts)

  1. Anonymous
    Unregistered
    Posted 3 years ago #

    Hey,

    Im having issues integrating the RSS feeds of my WP site into my html.
    This is the code im using

    <div class="smalltext4">
    				<?php
    $RSSfeedURL = "http://feeds.feedburner.com/Ezresidential";
    
    $RSSfeedURL=str_replace('http://','',$RSSfeedURL);$host=explode('/',$RSSfeedURL,2);
    $host=$host[0];$path='/'.trim(str_replace($host,'',$RSSfeedURL),'/');
    $fp = fsockopen($host,80,$errno,$errstr,30);$html='';
    fwrite($fp,"GET $path HTTP/1.1\r\nHost: $host\r\nUser-agent: Test\r\nConnection: Close\r\n\r\n");
    while(!feof($fp))$html.=fgets($fp, 128);fclose($fp);$html=explode('<item>',$html);
    $x=0;foreach($html as $h){if($x>0){
    $title=explode('<title>',$h);$title=explode('</title>',$title[1]);$title=$title[0];
    $link=explode('<link>',$h);$link=explode('</link>',$link[1]);$link=$link[0];
    $description=explode('<description>',$h);$description=explode('</description>',$description[1]);
    $description=$description[0];
    echo "<p>
    	<a href=\"$link\">$title</a><br />
    	<i>$description</i>
    </p>
    ";
    }$x++;}
    ?>
    			</div>

    Its embedded ok, but its adding random characters to the end of titles and descriptions...
    Website is http://ezres.com.au
    The embedded RSS feed is far left

  2. Anonymous
    Unregistered
    Posted 3 years ago #

    Any ideas on this one guys?

  3. Ogre
    Member
    Posted 3 years ago #

    Probably noise left over from opening a socket to get the file. Why not just use "file_get_contents()" instead? It works with urls not just local files and should simplify your code considerably.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.