コード例 #1
0
ファイル: box.php プロジェクト: p-drolima/twitter-thesis-box
    public function html($args = array())
    {
        global $thesis;
        extract($args = is_array($args) ? $args : array());
        // this method combines all of our options into a single array
        // instance based options take precedence over class based options.
        $options = $thesis->api->get_options(array_merge($this->_, $this->_options()), $this->options);
        //        $html = !empty($options['html']) ? $options['html'] : 'p';
        // We have now added our post meta option to our $string variable
        // Since the post meta is checked first, it will output if it exists else it will continue
        $message = array(!empty($this->options['consumer_key']) ? $this->options['consumer_key'] : (!empty($options['consumer_key']) ? $options['consumer_key'] : ''), !empty($this->options['consumer_secret']) ? $this->options['consumer_secret'] : (!empty($options['consumer_secret']) ? $options['consumer_secret'] : ''), !empty($this->options['oauth_token']) ? $this->options['oauth_token'] : (!empty($options['oauth_token']) ? $options['oauth_token'] : ''), !empty($this->options['oauth_secret']) ? $this->options['oauth_secret'] : (!empty($options['oauth_secret']) ? $options['oauth_secret'] : ''), !empty($this->options['username']) ? $this->options['username'] : (!empty($options['username']) ? $options['username'] : ''), !empty($this->options['tweet_count']) ? $this->options['tweet_count'] : (!empty($options['tweet_count']) ? $options['tweet_count'] : ''));
        $GLOBALS = $message;
        include_once 'include/twitter.php';
        //-------------------------------------------------------------- Timeline HTML output
        echo '<ul id="tweet-list" class="tweet-list">';
        # The tweets loop
        foreach ($twitter_data as $tweet) {
            $retweet = $tweet['retweeted_status'];
            $isRetweet = !empty($retweet);
            # Retweet - get the retweeter's name and screen name
            $retweetingUser = $isRetweet ? $tweet['user']['name'] : null;
            $retweetingUserScreenName = $isRetweet ? $tweet['user']['screen_name'] : null;
            # Tweet source user (could be a retweeted user and not the owner of the timeline)
            $user = !$isRetweet ? $tweet['user'] : $retweet['user'];
            $userName = $user['name'];
            $userScreenName = $user['screen_name'];
            $userAvatarURL = stripcslashes($user['profile_image_url']);
            $userAccountURL = 'http://twitter.com/' . $userScreenName;
            # The tweet
            $id = $tweet['id'];
            $formattedTweet = !$isRetweet ? formatTweet($tweet['text']) : formatTweet($retweet['text']);
            $statusURL = 'http://twitter.com/' . $userScreenName . '/status/' . $id;
            $date = timeAgo($tweet['created_at']);
            # Reply
            $replyID = $tweet['in_reply_to_status_id'];
            $isReply = !empty($replyID);
            # Tweet actions (uses web intents)
            $replyURL = 'https://twitter.com/intent/tweet?in_reply_to=' . $id;
            $retweetURL = 'https://twitter.com/intent/retweet?tweet_id=' . $id;
            $favoriteURL = 'https://twitter.com/intent/favorite?tweet_id=' . $id;
            ?>
            <li id="<?php 
            echo 'tweetid-' . $id;
            ?>
" class="tweet<?php 
            if ($isRetweet) {
                echo ' is-retweet';
            }
            if ($isReply) {
                echo ' is-reply';
            }
            if ($tweet['retweeted']) {
                echo ' visitor-retweeted';
            }
            if ($tweet['favorited']) {
                echo ' visitor-favorited';
            }
            ?>
">
                <div class="tweet-info">
                    <div class="user-info">
                        <a class="user-avatar-link" href="<?php 
            echo $userAccountURL;
            ?>
">
                            <img class="user-avatar" src="<?php 
            echo $userAvatarURL;
            ?>
">
                        </a>
                        <p class="user-account">
                            <a class="user-name" href="<?php 
            echo $userAccountURL;
            ?>
"><strong><?php 
            echo $userName;
            ?>
</strong></a>
                            <a class="user-screenName" href="<?php 
            echo $userAccountURL;
            ?>
">@<?php 
            echo $userScreenName;
            ?>
</a>
                        </p>
                    </div>
                    <a class="tweet-date permalink-status" href="<?php 
            echo $statusURL;
            ?>
" target="_blank">
                        <?php 
            echo $date;
            ?>
                    </a>
                </div>
                <blockquote class="tweet-text">
                    <?php 
            echo '<p>' . $formattedTweet . '</p>';
            echo '<p class="tweet-details">';
            if ($isReply) {
                echo '
<a class="link-reply-to permalink-status" href="http://twitter.com/' . $tweet['in_reply_to_screen_name'] . '/status/' . $replyID . '">
In reply to...
</a>
';
            }
            if ($isRetweet) {
                echo '
<span class="retweeter">
Retweeted by <a class="link-retweeter" href="http://twitter.com/' . $retweetingUserScreenName . '">' . $retweetingUser . '</a>
</span>
';
            }
            echo '<a class="link-details permalink-status" href="' . $statusURL . '" target="_blank">Details</a></p>';
            ?>
                </blockquote>
                <div class="tweet-actions">
                    <a class="action-reply" href="<?php 
            echo $replyURL;
            ?>
">Reply</a>
                    <a class="action-retweet" href="<?php 
            echo $retweetURL;
            ?>
">Retweet</a>
                    <a class="action-favorite" href="<?php 
            echo $favoriteURL;
            ?>
">Favorite</a>
                </div>
            </li>
        <?php 
        }
        # End tweets loop
        # Close the timeline list
        echo '</ul>';
    }
コード例 #2
0
<?php 
foreach ($twitter_data as $tweet) {
    //$retweet = $tweet['retweeted_status'];
    $isRetweet = !empty($retweet);
    # Retweet - get the retweeter's name and screen name
    $retweetingUser = $isRetweet ? $tweet['user']['name'] : null;
    $retweetingUserScreenName = $isRetweet ? $tweet['user']['screen_name'] : null;
    # Tweet source user (could be a retweeted user and not the owner of the timeline)
    $user = !$isRetweet ? $tweet['user'] : $retweet['user'];
    $userName = $user['name'];
    $userScreenName = $user['screen_name'];
    $userAvatarURL = stripcslashes($user['profile_image_url']);
    $userAccountURL = 'http://twitter.com/' . $userScreenName;
    # The tweet
    $id = $tweet['id'];
    $formattedTweet = !$isRetweet ? formatTweet($tweet['text']) : formatTweet($retweet['text']);
    $statusURL = 'http://twitter.com/' . $userScreenName . '/status/' . $id;
    $date = timeAgo($tweet['created_at']);
    # Reply
    $replyID = $tweet['in_reply_to_status_id'];
    $isReply = !empty($replyID);
    # Tweet actions (uses web intents)
    $replyURL = 'https://twitter.com/intent/tweet?in_reply_to=' . $id;
    $retweetURL = 'https://twitter.com/intent/retweet?tweet_id=' . $id;
    $favoriteURL = 'https://twitter.com/intent/favorite?tweet_id=' . $id;
    ?>
				<!--HERE'S THE RESULT-->
				<li >
					<a  href="<?php 
    echo $userAccountURL;
    ?>
コード例 #3
0
ファイル: api-twitter.php プロジェクト: abditag2/twitteroauth
/**
 * returns the last 20 tweets that user was mentioned in. each mention is formatted such that there are links to the users and hashtags
 * for an example look at function getLast20MentionAsAnArray
 *
 * @param $access_token
 * @return array[][] an array of arrays each with one element
 * $oneTweet['text']
 */
function getLast20MentionAsAnArray($access_token)
{
    $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);
    $mentions = $connection->get("statuses/mentions_timeline");
    $rv = array();
    foreach ($mentions as $tweet) {
        $oneTweet = array();
        $tweet_text = $tweet->text;
        //get the tweet
        $tweet_text = formatTweet($tweet_text);
        $oneTweet['text'] = $tweet_text;
        $rv[] = $oneTweet;
    }
    return $rv;
}
コード例 #4
0
ファイル: index.php プロジェクト: msuli/TwitterTimeline
You are free to use the following demo code for any purpose you see fit.

-->

<?php 
define('INCLUDE_CHECK', 1);
require "functions.php";
require "connect.php";
// remove tweets older than 1 hour to prevent spam
mysql_query("DELETE FROM demo_twitter_timeline WHERE id>1 AND dt<SUBTIME(NOW(),'0 1:0:0')");
//fetch the timeline
$q = mysql_query("SELECT * FROM demo_twitter_timeline ORDER BY ID DESC");
$timeline = '';
while ($row = mysql_fetch_assoc($q)) {
    $timeline .= formatTweet($row['tweet'], $row['dt']);
    //var_dump($row);
}
// fetch the latest tweet
$lastTweet = '';
//$result=mysql_fetch_array(mysql_query("SELECT tweet FROM demo_twitter_timeline ORDER BY id DESC LIMIT 1"));
//var_dump($result);
list($lastTweet) = mysql_fetch_array(mysql_query("SELECT tweet FROM demo_twitter_timeline ORDER BY id DESC LIMIT 1"));
//var_dump($lastTweet);
if (!$lastTweet) {
    $lastTweet = "You don't have any tweets yet!";
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">