Results 1 to 5 of 5

Thread: [RESOLVED] PHP RSS parser, wont display anything

  1. #1

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Resolved [RESOLVED] PHP RSS parser, wont display anything

    this is for my site:
    http://staticfx.com/forums/bb3portal.php

    on the left side, it says Gametab.. but there should be links appearing below it

    in my bb3portal.php file I have this:
    PHP Code:
    include($phpbb_root_path 'bb3portal/block/rss_gametab.'.$phpEx); 
    the rss_gametab.php has this:
    PHP Code:
    <?php
    /*
    *
    * @name rss_gametab.php
    * @package phpBB3 Portal  a.k.a canverPortal
    * @version $Id: rss_gametab.html,v 1.0 2007/04/01 20:35:47 staticFX Exp $
    * @license http://opensource.org/licenses/gpl-license.php GNU Public License 
    *
    */
    if (!defined('IN_PHPBB'))
    {
        exit;
    }

    /**
    */

    $keyword="";
    $nr_news=6;

    $file 'http://www.gametab.com/services/rss/topnews-past6hrs.php';

    $rss_channel = array();
    $currently_writing "";
    $main "";
    $item_counter 0;

    function 
    startElement($parser$name$attrs) {
           global 
    $rss_channel$currently_writing$main;
           switch(
    $name) {
               case 
    "RSS":
               case 
    "RDF:RDF":
               case 
    "ITEMS":
                   
    $currently_writing "";
                   break;
               case 
    "CHANNEL":
                   
    $main "CHANNEL";
                   break;
               case 
    "IMAGE":
                   
    $main "IMAGE";
                   
    $rss_channel["IMAGE"] = array();
                   break;
               case 
    "ITEM":
                   
    $main "ITEMS";
                   break;
               default:
                   
    $currently_writing $name;
                   break;
           }
    }

    function 
    endElement($parser$name) {
           global 
    $rss_channel$currently_writing$item_counter;
           
    $currently_writing "";
           if (
    $name == "ITEM") {
               
    $item_counter++;
           }
    }

    function 
    characterData($parser$data) {
        global 
    $rss_channel$currently_writing$main$item_counter;
        if (
    $currently_writing != "") {
            switch(
    $main) {
                case 
    "ITEMS":
                    if (isset(
    $rss_channel[$main][$item_counter][$currently_writing])) {
                        
    $rss_channel[$main][$item_counter][$currently_writing] .= $data;
                    } else {
                        
    //print ("rss_channel[$main][$item_counter][$currently_writing] = $data<br>");
                        
    $rss_channel[$main][$item_counter][$currently_writing] = $data;
                    }
                    break;
            }
        }
    }

    $xml_parser xml_parser_create();
    xml_set_element_handler($xml_parser"startElement""endElement");
    xml_set_character_data_handler($xml_parser"characterData");
    /*
    if (!($fp = fopen($file, "r"))) {
        die("could not open XML input");
    }

    /*
    while ($data = fread($fp, 4096)) {
        if (!xml_parse($xml_parser, $data, feof($fp))) {
            die(sprintf("XML error: %s at line %d",
                        xml_error_string(xml_get_error_code($xml_parser)),
                        xml_get_current_line_number($xml_parser)));
        }
    }
    */
    $data=curl_string($file);
    xml_parse($xml_parser,$data);
    xml_parser_free($xml_parser);

    // putting in array
    $news=array();
    if (isset(
    $rss_channel["ITEMS"])) 
    {
        if (
    count($rss_channel["ITEMS"]) > 0
            for(
    $i 0;$i count($rss_channel["ITEMS"]);$i++) $news[]=$rss_channel["ITEMS"][$i];
    }
    $c=0;

    foreach(
    $news as $key=>$val)
    {
        while(
    $c<$nr_news)
        {
            
    $template->assign_block_vars('gametab', array(
            
    'RCD' => "<a href=" $val['LINK'] . ">" $val['TITLE'] . "</a>")
            );
        }
        
    $c++;
    }

    function 
    curl_string ($url,$user_agent='Mozilla 4.0'){

           
    $ch curl_init();

           
    curl_setopt ($chCURLOPT_URL$url);
           
    curl_setopt ($chCURLOPT_USERAGENT$user_agent);
           
    curl_setopt ($chCURLOPT_HEADER0);
           
    curl_setopt ($chCURLOPT_RETURNTRANSFER1);
           
    curl_setopt ($chCURLOPT_FOLLOWLOCATION1);
           
    curl_setopt ($chCURLOPT_TIMEOUT120);
           
    $result curl_exec ($ch);
           
    curl_close($ch);
           return 
    $result;
      
    }
    ?>
    then in my rss_gametab.html i have this:
    Code:
    <!-- $Id: rss_gametab.html,v 1.0 2007/04/01 20:35:47 staticFX Exp $ //-->
    <html>
    	<table class="tablebg" cellspacing="1" width="100%">
    		<tr>
    			<td class="cat"><h4>Gametab News<h4>
    				</td>
    		</tr>
    		<!-- BEGIN rss_gametab -->
    		<tr>
    			<td class="row1">{gametab.RCD}</td>
    		</tr>
    		<!-- END rss_gametab -->
    </table>
    <br/>
    </html>
    and in the portal_main.html i am including it

    Code:
    <!--// [+] rss gametab //-->
          <!-- INCLUDE bb3portal/block/rss_gametab.html -->
    <!--// [-] rss gametab //-->
    i set it up like all the other "parts" of the portal... but it just wont display?


    any ideas???
    Last edited by Static; Apr 2nd, 2007 at 09:57 AM.
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: PHP RSS parser, wont display anything

    It looks as though the script offers two possible methods of downloading the feed data. Try the other one.

    Uncomment:
    PHP Code:
    /*
    if (!($fp = fopen($file, "r"))) {
        die("could not open XML input");
    }

    /*
    while ($data = fread($fp, 4096)) {
        if (!xml_parse($xml_parser, $data, feof($fp))) {
            die(sprintf("XML error: %s at line %d",
                        xml_error_string(xml_get_error_code($xml_parser)),
                        xml_get_current_line_number($xml_parser)));
        }
    }
    */ 
    Comment:
    PHP Code:
    $data=curl_string($file);
    xml_parse($xml_parser,$data);
    xml_parser_free($xml_parser); 
    And see how that goes.

  3. #3

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: PHP RSS parser, wont display anything

    nope... i think its in this:

    PHP Code:
    foreach($news as $key=>$val)
    {
        if(
    $c<$nr_news)
        {
            
    $template->assign_block_vars('oneup', array(
            
    'LINK' => $val['LINK'],
            
    'TITLE' => $val['TITLE'])
            );
        }
        
    $c++;

    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  4. #4

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: PHP RSS parser, wont display anything

    see: here it is raw.. it works
    http://staticfx.com/forums/bb3portal...rss_parser.php

    but when I try to dump them to a variable like everything else is done.. nothing comes out!
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  5. #5

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: PHP RSS parser, wont display anything

    got it.. finally
    changed to a different rss feed, then tweaked a few things

    post in my forums if you want to know the solution
    no time to post it right now
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width