Read rss based news and reviews from other website

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • neovantage
    New Member
    • Aug 2008
    • 245

    Read rss based news and reviews from other website

    Hey all,
    I want to read news and reviews from a website


    and want to populate on my website. How can i read that rss and show on my website using php

    kind regards,
    Mohsin Rafique
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    Originally posted by neovantage
    How can i read that rss
    any XML reader will do (DOMDocument, SimpleXML, …)

    Originally posted by neovantage
    and show on my website using php
    you could use XSLT to make the RSS into HTML directly. or use the XML reader to output the appropriate data.

    Comment

    • neovantage
      New Member
      • Aug 2008
      • 245

      #3
      Hey Sir,
      I have found a script which do this all for you and we just needs to pass the RSS URl of the website to whom we want to grab the news.

      It's really very nice script.
      I want to share this with this great community of experts as may be this will be helpful for those like me.

      here is the URL: A PHP script to get the contents of a remote RSS file

      Code:
      <?
      /*
      ======================================================================
      Get, cache, and output contents of a RSS XML file
      Author: George at JavaScriptKit.com/ DynamicDrive.com
      Created: Feb 1st, 2006. Updated: Feb 1st, 2006
      ======================================================================
      */
      
      header('Content-type: text/xml');
      
      // -------------------------------------------------------------------
      // Enter list of possible RSS feeds to fetch inside array:
      // -------------------------------------------------------------------
      
      $rsslist=array(
      "CNN" => "http://rss.cnn.com/rss/cnn_topstories.rss",
      "BBC" => "http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml",
      "news.com" => "http://news.com.com/2547-1_3-0-5.xml",
      "slashdot" => "http://rss.slashdot.org/Slashdot/slashdot",
      "dynamicdrive" => "http://www.dynamicdrive.com/export.php?type=new"
      );
      
      $cachefolder="cache"; //path to cache directory. No trailing "/". Set dir permission to read/write!
      
      // -------------------------------------------------------------------
      // Determine which RSS file to actually fetch
      // Based on the value of the "id" parameter of the URL string mapping to the RSS array's key
      // -------------------------------------------------------------------
      
      $rssid=$_GET['id'];
      $rssurl=isset($rsslist[$rssid])? $rsslist[$rssid] : die("Error: Can't find requested RSS in list.");
      $localfile=$cachefolder. "/" . urlencode($rssurl); //Name cache file based on RSS URL
      
      // -------------------------------------------------------------------
      // Get the minutes to cache the local RSS file based on "cachetime" parameter of URL string
      // -------------------------------------------------------------------
      
      $cacheminutes=(int) $_GET["cachetime"]; //typecast "cachetime" parameter as integer (0 or greater)
      
      // -------------------------------------------------------------------
      // fetchfeed() gets the contents of an external RSS feed,
      // and saves its contents to the "cached" file on the server
      // -------------------------------------------------------------------
      
      function fetchfeed(){
      global $rssurl, $localfile;
      $contents=file_get_contents($rssurl); //fetch RSS feed
      $fp=fopen($localfile, "w");
      fwrite($fp, $contents); //write contents of feed to cache file
      fclose($fp);
      }
      
      // -------------------------------------------------------------------
      // outputrsscontent() outputs the contents of a RSS feed using the cached local RSS file
      // It checks if a cached version of the RSS feed is available, and if not, creates one first.
      // -------------------------------------------------------------------
      
      function outputrsscontent(){
      global $rssurl, $localfile, $cacheminutes;
      if (!file_exists($localfile)){ //if cache file doesn't exist
      touch($localfile); //create it
      chmod($localfile, 0666);
      fetchfeed(); //then populate cache file with contents of RSS feed
      }
      else if (((time()-filemtime($localfile))/60)>$cacheminutes) //if age of cache file great than cache minutes setting
      fetchfeed();
      readfile($localfile); //return the contents of the cache file
      }
      
      outputrsscontent();
      ?>

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        so you didn't want to process the RSS file in the first place?

        EDIT:
        better use $_GLOBAL['name'] than global $name

        maybe OOP can improve the code even more.

        Comment

        • neovantage
          New Member
          • Aug 2008
          • 245

          #5
          i don't get you sir.

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            I thought you wanted to do anything to the RSS. but looking at the script, it does only fetch the feed, thus my question.

            Comment

            • neovantage
              New Member
              • Aug 2008
              • 245

              #7
              yep that's all i want to do for the time being now Sir

              Comment

              • Dormilich
                Recognized Expert Expert
                • Aug 2008
                • 8694

                #8
                then I misunderstood your question. the mentioned techniques are used to process RSS (which obviously includes loading)…

                Comment

                • neovantage
                  New Member
                  • Aug 2008
                  • 245

                  #9
                  On more question sir i am stuck in Thickbox Image Gallery

                  I have integrated Thickbox Gallery images for multiple images. So that once a member/client/visitor view the images he/she can navigate easily.

                  It just do not show any image if i used it's property rel means same rel element and value. It does not work. Can some body view on my script and tell me what is the problem behind this issue.
                  here is the live demo of the my work

                  Go to this link


                  Then click on Start Finding button. Once the page will open it show only one record. Click on Dealer Enquiry Link or click on images. it will take to you on the detail page. There you will see the pictures list and here i integrated Thickbox image gallery. when you will click on thumbnail then you will get my problem that it loads nothing just keep on browsing the page n that's it

                  kindly solve my problem Sir.

                  Comment

                  • Dormilich
                    Recognized Expert Expert
                    • Aug 2008
                    • 8694

                    #10
                    I've alread read that…

                    please respect the Posting Guidelines and don't hijack your own thread.

                    Comment

                    Working...