Пример #1
0
    $password = "******";
    // initialize the twitter class
    $twitter = new Twitter($username, $password);
    // fetch user's timeline in xml format
    $xml = $twitter->getUserTimeline();
    $twitter_status = new SimpleXMLElement($xml);
    $i = 0;
    foreach ($twitter_status->status as $status) {
        if ($i < 10) {
            if ($i == 0) {
                echo "\t\t\t\t";
            } else {
                echo "\n\t\t\t\t";
            }
            echo '<p>';
            $tweet = toLink($status->text);
            echo $tweet;
            echo '<br />';
            echo "\n\t\t\t\t";
            $date = preg_split("/[\\s,:]+/", $status->created_at);
            echo '<em>' . $date[1] . ' ' . (0 + $date[2]) . ', ' . $date[3] . ':' . $date[4] . '</em></p>';
            $i++;
        }
    }
} catch (Exception $e) {
    die('ERROR: ' . $e->getMessage());
}
echo "\n";
?>
			</div><!--googleon: snippet-->
		</div>
Пример #2
0
<?php

include 'TwitterSearch.php';
if ($_POST['twitterq']) {
    $twitter_query = $_POST['twitterq'];
    $search = new TwitterSearch($twitter_query);
    $results = $search->results();
    foreach ($results as $result) {
        echo '<div class="twitter_status">';
        echo '<img src="' . $result->profile_image_url . '" class="twitter_image">';
        $text_n = toLink($result->text);
        echo $text_n;
        echo '<div class="twitter_small">';
        echo '<strong>From:</strong> <a href="http://www.twitter.com/' . $result->from_user . '">' . $result->from_user . '</a>: ';
        echo '<strong>at:</strong> ' . $result->created_at;
        echo '</div>';
        echo '</div>';
    }
}