Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   CD Forum Support (http://www.chiefdelphi.com/forums/forumdisplay.php?f=8)
-   -   CD Feed (http://www.chiefdelphi.com/forums/showthread.php?t=24871)

Robby 06-02-2004 22:16

CD Feed
 
I was looking through the php script found in the nrg.chaosnet.org repository and was trying to figure out how to access the thread id value so that i could create a link to that specific thread using the url chiefdelphi.com/forums/showthread.php?t=[the desired thread #]. Is this possible? or is there some other way of doing it?

Jeremy_Mc 06-02-2004 22:23

Re: CD Feed
 
Quote:

Originally Posted by Robby
I was looking through the php script found in the nrg.chaosnet.org repository and was trying to figure out how to access the thread id value so that i could create a link to that specific thread using the url chiefdelphi.com/forums/showthread.php?t=[the desired thread #]. Is this possible? or is there some other way of doing it?

You would have to use an RSS parser I think...

I have one made up that's going on our new site...if anyone would like, I can post it in the White Papers.

It's really just a modded version of what Brandon had up here before i beileve...I'd have to look again.

Brandon Martus 06-02-2004 22:58

Re: CD Feed
 
You want the threadid via the XML? .. or you want to get it just by browsing?

Quote:

Originally Posted by Robby
I was looking through the php script found in the nrg.chaosnet.org repository and was trying to figure out how to access the thread id value so that i could create a link to that specific thread using the url chiefdelphi.com/forums/showthread.php?t=[the desired thread #]. Is this possible? or is there some other way of doing it?


Guest 07-02-2004 02:14

Re: CD Feed
 
Here's some new code that links to the correct CD thread.

Unfortunately, the external.xml that CD provides only gives the thread's author, not the post's author. I hope this changed soon ;)

You can see the following code in action at: http://nrg.chaosnet.org/resource/pro...eed/cdfeed.php

The code is also stored in the repository, as usual...
PHP Code:

<?php 
// If you want to use this PHP code, provide credit to [removed]
$cdfeed "[url="http://www.chiefdelphi.com/forums/external.php?type=XML"]http://www.chiefdelphi.com/forums/external.php?type=XML[/url]"; 
$fp fopen($cdfeed"r") or die("<b>Unable read ChiefDelphi feed!</b>\n"); 
while(!
feof($fp)) 
    { 
    
$xmld $xmld.fgets($fp1024); 
    } 
$open_stack = array(); 
$atts_stack = array(); 
$parser xml_parser_create(); 
xml_set_element_handler($parser"start_handler""end_handler"); 
xml_set_character_data_handler($parser"character_handler"); 
xml_parser_set_option($parserXML_OPTION_CASE_FOLDING,0); 
xml_parse($parser$xmld); 
xml_parser_free($parser); 
function 
start_handler($p$name$atts
    { 
    global 
$open_stack
        global 
$atts_stack
    global 
$cdthreads;
    
$open_stack[] = array($name,"",$atts); 
        if (
$name == "thread"){ 
               
$cdthreads[]=array("id"=>$atts['id'],"title"=>"","auth"=>"","time"=>0,"date"=>0);
               
$id=$atts['id'];
               print 
"<a href=\"<A href="http://www.chiefdelphi.com/forums/showthread.php?t=$id\">n">http://www.chiefdelphi.com/forums/showthread.php?t=$id\">\n"; 
        

    } 
function 
character_handler($p$txt
    { 
    global 
$open_stack
    
$cur_index count($open_stack)-1
    
$open_stack[$cur_index][1].=$txt
    } 
function 
end_handler($p$name
    { 
    global 
$open_stack
    
$el array_pop($open_stack); 
        if (
$name == "thread"){ 
               print 
"</a>\n"
        } 
    if (
$name == "title"
        { 
        echo 
"<b>$el[1]</b><br>"
         
$cdthreads[count($cdthreads)-1]['title']=$el[1];
        } 
    if (
$name == "author"
        { 
        echo 
"By <i>$el[1]</i>"
         
$cdthreads[count($cdthreads)-1]['auth']=$el[1];
        } 
    if (
$name == "date"
        { 
        echo 
"On $el[1],"
         
$cdthreads[count($cdthreads)-1]['date']=$el[1];
        } 
    if (
$name == "time"
        { 
        echo 
" at $el[1]<p>"
         
$cdthreads[count($cdthreads)-1]['time']=$el[1];
        } 

    } 
// At this point, all the threads have been printed out if PRINTOUT equaled one
// Also all the threads are stored in $cdthreads associative array.

?>


Robby 07-02-2004 08:35

Re: CD Feed
 
Thank you, this is pretty much what I was looking for.

Quote:

Originally Posted by SilverStar
Here's some new code that links to the correct CD thread.

Unfortunately, the external.xml that CD provides only gives the thread's author, not the post's author. I hope this changed soon ;)

You can see the following code in action at: http://nrg.chaosnet.org/resource/pro...eed/cdfeed.php

The code is also stored in the repository, as usual...
PHP Code:

<?php 
// If you want to use this PHP code, provide credit to [removed]
$cdfeed "[url="http://www.chiefdelphi.com/forums/external.php?type=XML"]http://www.chiefdelphi.com/forums/external.php?type=XML[/url]"; 
$fp fopen($cdfeed"r") or die("<b>Unable read ChiefDelphi feed!</b>\n"); 
while(!
feof($fp)) 
    { 
    
$xmld $xmld.fgets($fp1024); 
    } 
$open_stack = array(); 
$atts_stack = array(); 
$parser xml_parser_create(); 
xml_set_element_handler($parser"start_handler""end_handler"); 
xml_set_character_data_handler($parser"character_handler"); 
xml_parser_set_option($parserXML_OPTION_CASE_FOLDING,0); 
xml_parse($parser$xmld); 
xml_parser_free($parser); 
function 
start_handler($p$name$atts
    { 
    global 
$open_stack
        global 
$atts_stack
    global 
$cdthreads;
    
$open_stack[] = array($name,"",$atts); 
        if (
$name == "thread"){ 
               
$cdthreads[]=array("id"=>$atts['id'],"title"=>"","auth"=>"","time"=>0,"date"=>0);
               
$id=$atts['id'];
               print 
"<a href=\"<A href="http://www.chiefdelphi.com/forums/showthread.php?t=$id\">n">http://www.chiefdelphi.com/forums/showthread.php?t=$id\">\n"; 
        

    } 
function 
character_handler($p$txt
    { 
    global 
$open_stack
    
$cur_index count($open_stack)-1
    
$open_stack[$cur_index][1].=$txt
    } 
function 
end_handler($p$name
    { 
    global 
$open_stack
    
$el array_pop($open_stack); 
        if (
$name == "thread"){ 
               print 
"</a>\n"
        } 
    if (
$name == "title"
        { 
        echo 
"<b>$el[1]</b><br>"
         
$cdthreads[count($cdthreads)-1]['title']=$el[1];
        } 
    if (
$name == "author"
        { 
        echo 
"By <i>$el[1]</i>"
         
$cdthreads[count($cdthreads)-1]['auth']=$el[1];
        } 
    if (
$name == "date"
        { 
        echo 
"On $el[1],"
         
$cdthreads[count($cdthreads)-1]['date']=$el[1];
        } 
    if (
$name == "time"
        { 
        echo 
" at $el[1]<p>"
         
$cdthreads[count($cdthreads)-1]['time']=$el[1];
        } 

    } 
// At this point, all the threads have been printed out if PRINTOUT equaled one
// Also all the threads are stored in $cdthreads associative array.

?>




All times are GMT -5. The time now is 12:57.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi