Jump to content

taestell

New Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by taestell

  1. Wow... that appears to solve the problem. Always check the obvious first...
  2. Anyone know why the script would work when I run it directly, but not when I include it in another page?
  3. I found a little PHP script to get my latest status from Twitter and display it on my site. The script works fine when I run it directly here. However, when I try to include it on my site here, I get the error: "Fatal error: Cannot instantiate non-existent class: simplexmlelement in /home/.roxysaurus/taestell/v2.travisestell.com/tae-tweet.php on line 23" I can not figure out why this error is occurring. The site is running PHP5. Here is the code from tae-tweet.php: <h3><span>Latest Tweet</span></h3> <?php // Example: Get a single tweet. $status = getTwitterStatus("taestell"); echo('<div class="footer-element"><blockquote><p>' . $status[0]['message'] . '</p></blockquote> <span class="attrib">—<a href="http://twitter.com/taestell">Me</a>, ' . $status[0]['time'] . '</span></div>'); /** * A simple Twitter status display script. * Useful as a status badge for JavaScript non-compliant browsers, where the * insertion of the status message must be performed on the server. * * @author Manas Tungare, manas@tungare.name * @version 1.1 * @copyright Manas Tungare, 2007 - 2009 and onwards. * @license Creative Commons Attribution ShareAlike 3.0. */ function getTwitterStatus($twitterUser, $howMany = 1) { $url = sprintf("http://twitter.com/statuses/user_timeline/%s.xml?count=%d", $twitterUser, $howMany); $parsed = new SimpleXMLElement(file_get_contents($url)); $tweets = array(); foreach($parsed->status as $status) { $message = preg_replace("/http:\/\/(.*?)\/[^ ]*/", '<a href="\\0">\\0</a>', $status->text); $time = niceTime(strtotime(str_replace("+0000", "", $status->created_at))); $tweets[] = array('message' => $message, 'time' => $time); } return $tweets; } /** * Formats a timestamp nicely with an adaptive "x units of time ago" message. * Based on the original Twitter JavaScript badge. Only handles past dates. * @return string Nicely-formatted message for the timestamp. * @param $time Output of strtotime() on your choice of timestamp. */ function niceTime($time) { $delta = time() - $time; if ($delta < 60) { return 'less than a minute ago'; } else if ($delta < 120) { return 'about a minute ago'; } else if ($delta < (45 * 60)) { return floor($delta / 60) . ' minutes ago'; } else if ($delta < (90 * 60)) { return 'about an hour ago'; } else if ($delta < (24 * 60 * 60)) { return 'about ' . floor($delta / 3600) . ' hours ago'; } else if ($delta < (48 * 60 * 60)) { return '1 day ago'; } else { return floor($delta / 86400) . ' days ago'; } } ?> Here is the code from index2.html: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xml:lang="en-us" xmlns="http://www.w3.org/1999/xhtml"> <head> <title>TravisEstell.com</title> <style type="text/css" media="screen,tv"> @import url("./screen.css"); </style> <base href="http://travisestell.com/" /> </head> <body> <?php include "/home/taestell/v2.travisestell.com/tae-navigation.php" ?> <h2>Home</h2> <div id="content"> <h3 class="section-title">Current</h3> <div class="current"> <p>I am now hosting a radio show called <a href="http://explorecincinnati.com/">Explore Cincinnati</a>, which focuses on urban development, local arts, culture, community, and regional news. It airs on Fridays at 10am on <a href="http://bearcastradio.com/">Bearcast Radio</a>, the University of Cincinnati’s Student Internet Radio Station. It is also <a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=303484646">podcasted</a> so that you can download the episodes and listen at any time. Visit <a href="http://explorecincinnati.com/">ExploreCincinnati.com</a> for more information.</p> </div><!-- .current --> <h3 class="section-title">Updates</h3> <div class="post"> <h4 class="date"> <span class="month" title="March">March</span> <span class="day">15</span> </h4><!-- .date --> <h5 class="post-title">New Design</h5> <p>Welcome to the new design of TravisEstell.com. Browse around and take a look at some examples of my work that I have posted.</p> </div><!-- .post --> </div><!-- #content --> </div><!-- #main-section --> <p class="necessary-evil"> </p> </div><!-- #zone-2 .zone --> <div id="zone-3" class="zone"> <div id="footer"> <h2>More fun</h2> <?php include "/home/taestell/v2.travisestell.com/tae-footer.php" ?> <?php include "/home/taestell/v2.travisestell.com/tae-tweet.php" ?> </div><!-- #footer --> <p class="necessary-evil"> </p> </div><!-- #zone-3 .zone --> <div id="zone-4" class="zone"> <div id="copyright"> <?php include "/home/taestell/v2.travisestell.com/tae-copyright.php" ?> </div><!-- #copyright --> </div><!-- #zone-4 .zone --> </body> </html> Any help would be appreciated! Thanks, Travis
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.