Announcement

Collapse
No announcement yet.

RSS2 Not working

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • RSS2 Not working

    Hi,

    I'm using this code to display the rss2 feed.

    When i put the Vbulletin RSS2 feed it works, but when i use my own feed url it doesnt work.


    VBulletin feed URL: http://www.vbulletin.com/forum/external.php?type=rss2

    My feed URL: http://www.REMOVED.com/cms/external.php?type=rss2

    PHP Code:
    <?php
    // ######################################################
    // ## configuration
     // ##
     // ## $rss2_file= 'http://www.vbulletin.com/forum/external.php?type=rss2';
     // ## Adjust this variable to point to your RSS2 feed
     
     
    $rss2_file 'http://www.REMOVED.com/cms/external.php?type=rss2';
     
     
    // ## configuration end
     // ######################################################
     // ## Do not touch code below!
     
     
     
    $is_item false;
     
    $tag '';
     
    $title '';
     
    $description '';
     
    $link '';
     
    $date '';
     
    $author '';
     
     function 
    character_data($parser$data)
     {
         global 
    $is_item$tag$title$description$link$date$author;
         if (
    $is_item)
         {
             switch (
    $tag)
             {
                 case 
    "TITLE":
                 
    $title .= $data;
                 break;
     
                 case 
    "DESCRIPTION":
                 
    $description .= $data;
                 break;
     
                 case 
    "LINK":
                 
    $link .= $data;
                 break;
     
                 case 
    "PUBDATE":
                 
    $date .= $data;
                 break;
     
                 case 
    "AUTHOR":
                 
    $author .= $data;
                 break;
             }
         }
     }
     
     function 
    begin_element($parser$name)
     {
         global 
    $is_item$tag;
         if (
    $is_item)
         {
             
    $tag $name;
         }
         else if (
    $name == "ITEM")
         {
             
    $is_item true;
         }
     }
     
     function 
    end_element($parser$name)
     {
         global 
    $is_item$title$description$link$date$author$rss2_output;
         if (
    $name == "ITEM")
         {
             
    $rss2_output .= "<dt><strong><a href='" trim($link) . "'>" htmlspecialchars(trim($title)) . "</a></strong> - " htmlspecialchars(trim($date)) . " by <em>" htmlspecialchars(trim($author)) . "</em></dt><dd>" htmlspecialchars(trim($description)) . "</dd>";
             
    $title "";
             
    $description "";
             
    $link "";
             
    $date "";
             
    $author "";
             
    $is_item false;
         }
     }
     
     
     
    $parser xml_parser_create();
     
     
    xml_set_element_handler($parser"begin_element""end_element");
     
    xml_set_character_data_handler($parser"character_data");
     
    $fp fopen($rss2_file,"r");
     
     while (
    $data fread($fp4096))
     {
         
    xml_parse($parser$datafeof($fp));        
     }
     
     
    fclose($fp);
     
    xml_parser_free($parser);
    ?>
     
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    <?php echo $rss2_output?>
    </body>
    </html>
    Last edited by newbie2007; Sun 17th Jun '07, 3:11am.

  • #2
    This is the error message it comes up with.

    HTML Code:
    Warning: fopen(http://www.REMOVED.com/cms/external.php?type=rss2) [function.fopen]: failed to open stream: Connection refused in /home/sites/REMOVED.com/public_html/new/TMPrrx49jhkvy.php on line 86
     
    Warning: fread(): supplied argument is not a valid stream resource in /home/sites/REMOVED.com/public_html/new/TMPrrx49jhkvy.php on line 88
     
    Warning: fclose(): supplied argument is not a valid stream resource in /home/sites/REMOVED.com/public_html/new/TMPrrx49jhkvy.php on line 93
    Last edited by newbie2007; Sun 17th Jun '07, 3:12am.

    Comment


    • #3
      Hi here is the above code in action:

      http://www.REMOVED.com/new/rsstest.php

      Here is the same code with the feed changed to vbulletin.com external feed:

      http://www.REMOVED.com/new/rsstestvb.php

      There isnt a single part of the code modified, and external data provider is enabled.

      You can check by clicking on the rss2 feed links on the first post.

      Thanks in advance for any help!
      Last edited by newbie2007; Sun 17th Jun '07, 3:12am.

      Comment


      • #4
        We can't offer official support for code modifications or for forums running modified code. But we do have a hacking site and forums, however, with people that may be willing to help you with this.

        Please visit http://www.vbulletin.org/forum/ and ask for help there in the appropriate forum.
        Kerry-Anne :)

        Twitter Blog

        www.peterska2.com www.worldnewszone.com www.popularusenetgroups.com www.superclickers.co.uk www.forumsforchrist.com www.browsergameplanet.com

        Comment


        • #5
          This is actually something Colin slapped together and posted here if I recall correctly...

          Reading the above, I believe the problem is that your host does not allow a "remote" fopen; IE: fopen cannot open an URL. Unfortunately, there is no way around this problem unless your host can resolve this issue for you. You should contact your host and tell them you need to use fopen to open an URL for your application, and they will tell you whether they can change it for you or they will not change it (for whatever reason they may have).
          Best Regards,
          Andy Huang

          Comment


          • #6
            Hi Andy,

            Thanks for that, i'll contact the host

            Comment


            • #7
              the problem seems to be that fopen cannot be used to display a feed thats based on the same site?

              I've put the code on another server and it seems to full the feed from my site, and i can pull another feed from that site.

              But the rss reader and the feed cannot reside on the same site for some reason!

              Comment

              widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
              Working...
              X