views:

471

answers:

2

$hometime= $Twitter->get_statusesHome_timeline();

Fatal error: Uncaught exception 'Exception' with message 'SimpleXMLElement::__construct() expects parameter 1 to be string

<?php
        include 'EpiCurl.php';
        include 'EpiOAuth.php';
        include 'EpiTwitter.php';
        include 'key.php';

        $Twitter = new EpiTwitter($consumerKey, $consumerSecret);
        $oauthToken='xxxxxxxxxxxxxxxxxxxxxxx';
        $oauthSecret='xxxxxxxxxxxxxxxxxxxxxxxxx';

             // user switched pages and came back or got here directly, stilled logged in
             $Twitter->setToken($oauthToken,$oauthSecret);
             $user= $Twitter->get_accountVerify_credentials();

       echo "<img src=\"{$user->profile_image_url}\">";
       echo "{$user->name}";


        $hometime= $Twitter->get_statusesHome_timeline();

        $twitter_status = new SimpleXMLElement($hometime);
        foreach($twitter_status->status as $status){
            echo '<div class="twitter_status">';
            foreach($status->user as $user){
                echo '<img src="'.$user->profile_image_url.'" class="twitter_image">';
                echo '<a href="http://www.twitter.com/'.$user-&gt;name.'"&gt;'.$user-&gt;name.'&lt;/a&gt;: ';
            }
            echo $status->text;
            echo '<br/>';
            echo '<div class="twitter_posted_at"><strong>Posted at:</strong> '.$status->created_at.'</div>';
            echo '</div>';
        }

             ?>
A: 

My best guess is that you might have turned off Warnings (and Notices) and that the

$hometime= $Twitter->get_statusesHome_timeline();

call doesn't return any xml but "false" because it can't connect (or something).

Did you try printing $hometime after the call ?

edorian
Catchable fatal error: Object of class EpiTwitterJson could not be converted to string
Srinivas Tamada
A: 

$hometime should be an array of status objects.

Try

<?php
$hometimeline = $Twitter->get_statusesHome_timeline();
foreach($hometimeline as $status){
    echo '<div class="twitter_status">';
    foreach($status->user as $user){
        echo '<img src="'.$user->profile_image_url.'" class="twitter_image">';
        echo '<a href="http://www.twitter.com/'.$user-&gt;name.'"&gt;'.$user-&gt;name.'&lt;/a&gt;: ';
    }
    echo $status->text;
    echo '<br/>';
    echo '<div class="twitter_posted_at"><strong>Posted at:</strong> '.$status->created_at.'</div>';
    echo '</div>';
}
abraham
No out put. blank
Srinivas Tamada
What does `var_dump($Twitter->get_statusesHome_timeline());` print to the page?
abraham