Results 1 to 2 of 2

Thread: Fatal error: Cannot instantiate non-existent class: simplexmlelement

  1. #1

    Fatal error: Cannot instantiate non-existent class: simplexmlelement

    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:
    Code:
    <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:
    Code:
    <!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&nbsp;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&nbsp;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">&nbsp;</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">&nbsp;</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

  2. #2
    tegwar champ
    United Nations mmi's Avatar
    Join Date
    Oct 2000
    Location
    is everything
    Posts
    7,774
    answer found here

    "Until I feared I would lose it, I never loved to read. One does not love breathing." — Harper Lee (Scout, in To Kill a Mockingbird)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. phpmyadmin.... fatal error?
    By wildmage in forum Server-side Forum
    Replies: 1
    Last Post: 12th December 2005, 03:05
  2. C++: program raised fatal error at runtime.
    By kAsPeR in forum Server-side Forum
    Replies: 6
    Last Post: 28th April 2004, 07:49
  3. Replies: 6
    Last Post: 27th June 2003, 16:28
  4. thiss class, or that class, based on id visibility: function for it
    By shawn gibson in forum Client-side forum
    Replies: 2
    Last Post: 18th April 2002, 21:13
  5. Error: Class doesn't suport automation
    By easot in forum Client-side forum
    Replies: 4
    Last Post: 13th June 2001, 22:12

Bookmarks

Posting Permissions

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