Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13
  1. #1
    Junior Member
    Join Date
    Mar 2006
    Posts
    18
    Member #
    12685
    Hi am new here so please excuse me if this is a stupid question.
    I am helping a DJ friend put a site together, he has a podcast set up on Yahoo.
    Currently we are able to display all the information about the podcast onto the site, apart from the actual mp3 file for people to download. I know this is contained in the ENCLOSURE tag but I am unsure how to get this to display on the webpage.
    Can anybody help?

  2.  

  3. #2
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,656
    Member #
    1234
    Liked
    137 times
    Do you have a link to somewhere that has a link to the podcast?
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com

  4. #3
    Senior Member duck444's Avatar
    Join Date
    Feb 2003
    Location
    east coast
    Posts
    402
    Member #
    751
    Liked
    2 times
    I think the answer to this question (if it's sufficiantly informative) should be made a sticky topic. There seems to be confusion over how to use someone else's rss feed on your site and creating your own. From what little I understand, they are two different processess and I am personally interested in the former.

  5. #4
    Junior Member
    Join Date
    Mar 2006
    Posts
    18
    Member #
    12685
    Thank you for replying so quickly.
    I'm pulling the information from an xml file generated from the yahoo podcast site
    http://www.ruforia.org/podcasts/ruforiaPodcast.xml
    The code i'm using is a freebie called 'RSS Fetch' which is shown below.
    Code:
    
    class rss_parser {
     var $update_interval = 60;    
     /* How often to fetch the rss file
        A cached version will be used between updates    */
     var $data_directory = "/home/neoprog/www/rss";
     /* Where to store the rss data from the feeds
        Note: an absolute path is better than a relative path here
        unless you plan on keeping the script to display the feeds
        in the same folder as this file and the feeds.   */
    
     /* NO NEED TO EDIT BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING  */
    
     var $rss_url;
     var $num_to_show;
     var $offset;  //added in version 0.4.3
     var $do_update;
     var $tags = array();
     var $content;
     var $rss = array();
     var $feed_title;
     var $feed_link;
     var $feed_description;
     var $my_html;
    
    
     function rss_parser($url, $numtoshow = 10, $html = "", $update = FALSE, $offset = 1)
     {
       $this->rss_url = $url;
       $this->num_to_show = $numtoshow;
       $this->do_update = $update;
       $this->my_html = preg_replace("/(#{.*?):(.*?})/", "\\1__\\2", $html); //xx:xx tag workaround
       $this->offset = --$offset;
    
       $this->content = $this->fetch_feed();
       $this->parse_feed();
       $this->show();
     }
    
     /* string */
     function fetch_feed()
     { 
       $url_parts = parse_url($this->rss_url);
       $filename = $url_parts['host'] . str_replace("/", ",", $url_parts['path']) . "_" . @$url_parts['query'];
       if(file_exists($this->data_directory . "/$filename")) {
         $last = filemtime($this->data_directory . "/$filename");
         if(time() - $last > $this->update_interval * 60 || $this->update_interval == 0) {
           $update = 1;
         }
       } else {
           $create= 1;
       }
       if($create == 1 || ($this->do_update == TRUE && $update == 1)) {
         $fp = @fsockopen($url_parts['host'], 80, $errno, $errstr, 5);
         if (!$fp) {
           echo "Couldn't open rss feed {$this->feed_url} in {$_SERVER['PHP_SELF']}<br />\n";
           return;
         }
         fputs($fp, "GET " . $url_parts['path'] . "?" . @$url_parts['query'] . " HTTP/1.0\r\n"
                   ."Host: " . $url_parts['host'] . "\r\n"
                   ."User-Agent: Drew's RSS Reader 0.1\r\n"
                   ."Connection: Close\r\n\r\n");
         while(!feof($fp)) {
           $rss_data .= @fgets($fp, 1024);
         }
         list(, $rss_data) = explode("\r\n\r\n", $rss_data, 2);
         $output = @fopen($this->data_directory . "/$filename", "w+");
         if(!$output) {
           return $rss_data;
         } else {
           flock($output, LOCK_EX);
           fputs($output, $rss_data);
           flock($output, LOCK_UN);
           fclose($output);
         }
       } //update
       return file_get_contents($this->data_directory . "/$filename");
     }
     /* void */
     function parse_feed()
     {
    
       preg_match("/<title>(.*?)<\/title>/", $this->content, $title);
       $this->feed_title = @$title[1];
       preg_match("/<link>(.*?)<\/link>/", $this->content, $link);
       $this->feed_link = @$link[1];
       preg_match("/<description>(.*?)<\/description>/", $this->content, $description);
       $this->feed_description = @$description[1];
       preg_match_all("/<item[^>]*>(.*?)<\/item>/s", $this->content, $items);
       if (sizeof($items[0]) == 0) {
         echo "No item elements found in rss feed.<br />\n";
       }
       for($i = 0; $i < sizeof($items[0]); ++$i) {
         preg_match_all("/(?:<([\w:]*)[^>]*>\s*(?:<!\[CDATA\[)?(.*?)(?:]]>)?\s*<\/\\1>)+?/si", preg_replace("/<item[^>]*>/", "", $items[0][$i]), $elements);
         for($j = 0; $j < sizeof($elements[0]); ++$j) {
           $elements[1][$j] = str_replace(":", "__", $elements[1][$j]);  //regex fix for items with : like dc:date
           $this->rss[$i][$elements[1][$j]] = trim(html_entity_decode($elements[2][$j]));
         }
       }
     }
    
     /* void */
     function show()
     {
       if($this->my_html == "") {
         $this->show_html();
       } else {
         $this->show_user_html();
       }
     }
     function show_html()
     {
       $show = (sizeof($this->rss)  > $this->num_to_show ? $this->num_to_show : sizeof($this->rss));
       for($i = $this->offset; $i < $this->offset + $show; ++$i) {
         echo "- <a href=\"{$this->rss[$i]['link']}\" target=\"_new\">{$this->rss[$i]['title']}</a><br />\n";
       }
     }
     function show_user_html()
     {
       $show = (sizeof($this->rss) > $this->num_to_show + $this->offset ? $this->num_to_show : sizeof($this->rss));
       $show = ($this->offset + $this->num_to_show > sizeof($this->rss) ? sizeof($this->rss) - $this->offset : $this->num_to_show);
       for($i = $this->offset; $i < $this->offset + $show; ++$i) {
         extract($this->rss[$i]);
         $item = preg_replace("/#\{([^}]+)}/e", "$\\1", $this->my_html);
         echo $item;
       }
     }
    } // end class
    
    ?>
    
    What i can do is get all the information the xml file apart from the 'enclosure' tag which holds the information about the mp3, location and file size. Below is the code I use to call the info to the site.
    Code:
     
    <?php
    include_once "./rss_fetch.php";
    $html  = "  <tr>\n";
    $html .= "    <td style='background-color: #DCF0FA; font-weight: bold; color: #000000; font-size: 13px;'>\n";
    $html .= "      <font size='+1'><a href='#{link}' target='_new'>#{title}</a></font><br />\n";
    $html .= "      #{description}<br />\n";
    $html .= "      <font size='2'>#{pubDate}<br /><br />\n";
    $html .= "    </td>\n";
    $html .= "  </tr>\n";
    $rss = new rss_parser("http://www.ruforia.org/podcasts/ruforiaPodcast.xml", 5, $html, 1);
    ?>
    I haven't got anything in for the enclosure at the mo as I haven't had anything work for it yet.
    Hope this makes things clearer
    Paul

  6. #5
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,656
    Member #
    1234
    Liked
    137 times
    Quote Originally Posted by duck444
    I think the answer to this question (if it's sufficiantly informative) should be made a sticky topic. There seems to be confusion over how to use someone else's rss feed on your site and creating your own. From what little I understand, they are two different processess and I am personally interested in the former.
    The former has been posted multiple times around the site actually.


    Paul T, what do you want to post on your site exactly? The podcast itself?
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com

  7. #6
    Junior Member
    Join Date
    Mar 2006
    Posts
    18
    Member #
    12685
    Yes wired that is what i'd like to do is the podcast.

    And thanks again for taking the time to have a look : )

  8. #7
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,656
    Member #
    1234
    Liked
    137 times
    Do you want to mirror the podcast (having an actual copy of it on your site), or just a link to it?
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com

  9. #8
    Senior Member duck444's Avatar
    Join Date
    Feb 2003
    Location
    east coast
    Posts
    402
    Member #
    751
    Liked
    2 times
    Paul,

    I don't know if this can help you but its been a great resource for me. Since you posted this thread I've been trying to find a way to get real rss on my site and found this place

    http://www.originotions.com/index.html

    Using it I was able to finally get rss on my site. Follow the directions (it's really simple) and you should be able to put non-javascript rss (detectable by search engines!) on your site with ease. I'm still working out the kinks...pics in the yahoo news feed I'm using currently aren't showing up...but if you want to use a news feed without pics it should work fine....another thing I don't like is the headlines are centered...not sure how to get them on the left....and, when I first uploaded the .php page yesterday, it didn't show up....today I went to double check...and there it was. hope this helps...duck

  10. #9
    Junior Member
    Join Date
    Mar 2006
    Posts
    18
    Member #
    12685
    Wired:
    I would like to link the podcast so i dont actually have to have the mp3 files on my server. And when the podcast is updated or a new one is added It will automatically update.
    Duck444:
    Thanks for the link and has been a helpful resource, but it is very similar to the code i've posted above (the out put is the same). This is still a valuable resource, as i'm trying to wrap my head around PHP.

    Thanks again for taking the time to answer my problem
    Paul

  11. #10
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,656
    Member #
    1234
    Liked
    137 times
    Ok, so you need some more PHP code to pull out the enclosure from the XML as a link.
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 08:03 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com