+ Reply to Thread
Results 1 to 3 of 3

Thread: Display your last BoxedThought on your website

  1. #1
    The_Magistrate's Avatar
    The_Magistrate is offline x10 Elder The_Magistrate is an unknown quantity at this point
    Join Date
    May 2005
    Location
    PA
    Posts
    559

    Display your last BoxedThought on your website

    If you don't already know what BoxedThoughts is, check out http://www.boxedthoughts.com. There is a complete explanation under the FAQ on that site, so I won't go into it here.

    If you use the site, you may have noticed the XML Metadata feature and wondered what it's for.... Basically, its so web developers can post information about their ThoughtStream on their personal websites. Check out this forum post for more information about the different features of the XML Metadata. http://www.boxedthoughts.com/newspea...opic.php?t=141

    Ok, to the reason for this post... here is a bit of code I wrote a while back that lets you use the XML Metadata and display BoxedThoughts stuff on your site.

    PHP Code:
    <?
       
    // (c) The_Magistrate 2006
       // Usage : bt.php?u=<<YOUR BT USERNUMBER HERE>>
       // or
       // Usage : bt.php?u=<<USERNUMBER>>&i=1
       // This script will retrieve the XHTML version of the last thought of the user specified by 
       // the variable u.
       // If i == 1 then information about the user will be displayed with the thought
      
       
    $filename "http://www.boxedthoughts.com/users/".$_GET['u']."/meta/last/xhtml";
       
    $data implode(""file($filename));   //  Store the information from the site in an array
       
    $parser xml_parser_create();  //  Create a new XML parser to extract the information
       
    xml_parser_set_option($parserXML_OPTION_CASE_FOLDING0);
       
    xml_parser_set_option($parserXML_OPTION_SKIP_WHITE1);
       
    xml_parse_into_struct($parser$data$values$tags);
       
    xml_parser_free($parser);

       
    $remain $values[5][value];   // Time remaining in seconds until next post is allowed
       
    $hours floor($remain 3600);  // Change the time remaining into useful hours
       
    $mins floor(($remain 3600) / 60);  // and seconds remaining.

       
    $username $values[2][value];  // The username of the BT user
       
    $URL $values[3][value];  //  URL to that user's thoughtstream
       
    $numposts $values[9][value];  // Number of thoughts by the user

       
    $title $values[12][value];  // Title of the last thought
       
    $class $values[13][value];  // CSS Class of the last thought
       
    $style $values[14][value];  // Border style of the last thought
       
    $content $values[15][value];  // Actual thought content
                   
       
    if($_GET['i'] == 1)  // If i is set in the URL, display the information about the user
       
    {
          echo 
    "<strong>Username</strong> : $username<br />\n"
              
    ."<strong>Num Posts</strong> : $numposts<br />\n"
              
    ."<strong>Timeleft</strong> : ".$hours."h ".$mins."m<br /><br />\n";
       }

       
    // Display the thought
       
    echo "<div title=\"$title\" id=\"preview\" class=\"$class\" style=\"$style\" onclick=\"javascript:document.location='http://www.boxedthoughts.com/users/".$_GET['u']."'\">$content</div><br />";
    ?>
    This script will only display the last thought of a user in XHTML, I'm pretty sure it'll work for the standard HTML version of the XML Metadata too. As for displaying the entire ThoughtStream, that would require some looping, but shouldn't be too hard. If anyone would like me to take a stab at it, I can hack out a full stream script.
    Getting Started | Terms of Service | Paid Hosting | Forum Rules | Free Server Status | Banned Countries

    If I have helped you through one of my posts, please click the
    blue checkbox on the right below my avatar to add to my reputation.

  2. #2
    lambada's Avatar
    lambada is offline x10 Elder lambada is an unknown quantity at this point
    Join Date
    Mar 2006
    Location
    Caister, Gt Yarmouth, Norfolk, ENGLAND
    Posts
    1,222

    Re: Display your last BoxedThought on your website

    I'd quite like you to have a stab at doing the looped version.

    Although this is very good as it is

    Well done.
    Lambada - the former Account Manager (before I resigned)




  3. #3
    Bryon is offline Administrator Bryon has disabled reputation
    Join Date
    Apr 2005
    Location
    Northfield, NH
    Posts
    7,608

    Re: Display your last BoxedThought on your website

    Nice script, I must say.

    Also I like seeing other's code that is clean, efficient, and nicely commented. I like it so much because I always see scripts or snippets of code that are horribly coded, that people show others and try to teach them with. Blahh.. You probably know what I mean. ;)

    Just wanted to say that.

+ Reply to Thread

Similar Threads

  1. Replies: 18
    Last Post: 09-25-2006, 04:32 PM
  2. googkle.com
    By dsfreak in forum Off Topic
    Replies: 17
    Last Post: 07-12-2006, 05:09 PM
  3. Showcase Website Awards
    By Kay in forum Graphics & Webdesign
    Replies: 2
    Last Post: 10-15-2005, 03:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers