4

I have been researching this topic for a few days now and i'm still non the wiser as on how to do it.

I want to get an RSS feed from forexfactory.com to my website, i want to do some formatting on whats happening and i also want the latest information from them (Although those last two points can wait as long as i have some more or feed running).

Preferably I'd like to develop this from the ground up if anyone knows of a tutorial or something i could use?

If not i will settle for using a third party API or something like that as long as i get to do some of the work.

I'm not sure what it is but there is something about RSS that i'm not getting so if anyone knows of any good, probably basic tutorials that would help me out a lot. It's kind of hard going through page after page of google searches.

Also i'm not to fussed on the language it's outputted in Javascript, PHP or HTML will be great though.

Thanks for the help.

ragebunny
  • 1,582
  • 10
  • 33
  • 53
  • 1
    Maybe a repeat question. There's quite a few of these already asked. Maybe this one can help you? http://stackoverflow.com/questions/2074795/getting-rss-feeds-on-website Maybe not what you are looking for but in particular, the SimplePie plugin is great. http://simplepie.org/ – Liam Spencer May 16 '12 at 09:31
  • And i didn't come across this when i was writing the post. I'm looking at Simlepie and in all fairness i think this might be what I'm looking for. @LiamSpencer – ragebunny May 16 '12 at 09:37
  • Nice one! I added an answer for you man. Good luck. – Liam Spencer May 16 '12 at 09:49

3 Answers3

3

It looks like SimplePie may be what you are looking for. It's a very basic RSS plugin which is quite easy to use and is customisable too. You can download it from the website.

You can use it at it's bare bones or you can delve deeper in to the plugin if you wish. Here's a demo on their website.

Liam Spencer
  • 936
  • 1
  • 11
  • 25
2

index.php

include('rss_class.php');

  $feedlist = new rss($feed_url);
  echo $feedlist->display(2,"Feed Title");

rss_class.php

<?php
 class rss {
        var $feed;
        function rss($feed){
            $this->feed = $feed;
        }

        function parse(){
            $rss = simplexml_load_file($this->feed);

            //print_r($rss);die; /// Check here for attributes

            $rss_split = array();

            foreach ($rss->channel->item as $item) {

              $title = (string) $item->title; 
              $link   = (string) $item->link; 
              $pubDate   = (string) $item->pubDate; 
              $description = (string) $item->description; 
              $image = $rss->channel->item->enclosure->attributes();
              $image_url =   $image['url'];

             $rss_split[] = '
                    <li>
                        <h5><a href="'.$link.'">'.$title.'</a></h5>
                        <span class="dateWrap">'.$pubDate.'</span>
                        <p>'.$description.'</p>
                        <a href="'.$link.'">Read Full Story</a>
                    </li>
                ';
            }
            return $rss_split;
        }

        function display($numrows,$head){

            $rss_split = $this->parse();
            $i = 0;
            $rss_data = '<h2>'.$head.'</h2><ul class="newsBlock">';
            while($i<$numrows){
              $rss_data .= $rss_split[$i];
              $i++;
            }
            $trim = str_replace('', '',$this->feed);
            $user = str_replace('&lang=en-us&format=rss_200','',$trim);


            $rss_data.='</ul>';

            return $rss_data;
        }
}
?>
Ravi Patel
  • 641
  • 1
  • 10
  • 18
0

I didn't incorporate the < TABLE > tags as there might be more than one article that you would like to display.

class RssFeed
{
    public $rss = "";

    public function __construct($article)
    {
      $this->rss = simplexml_load_file($article, 'SimpleXMLElement', LIBXML_NOERROR | LIBXML_NOWARNING);

      if($this->rss != false)
      {
        printf("<TR>\r\n");
        printf("<TD>\r\n");
        printf("<h3>%s</h3>\r\n", $this->rss->channel->title);
        printf("</TD></TR>\r\n");

        foreach($this->rss->channel->item as $value)
        {
          printf("<TR>\r\n");
          printf("<TD id=\"feedmiddletd\">\r\n");
          printf("<A target=\"_blank\" HREF=\"%s\">%s</A><BR/>\r\n", $value->link, $value->title);
          printf($value->description);
          printf("</TD></TR>\r\n");
        }
      }
    }
}