/**
  * How to display the widget on the screen.
  */
 function widget($args, $instance)
 {
     extract($args);
     /* Our variables from the widget settings. */
     $title = apply_filters('widget_title', isset($instance['title']) ? $instance['title'] : '');
     $twitter_username = isset($instance['twitter_username']) ? $instance['twitter_username'] : '';
     $twitter_consumer_key = isset($instance['twitter_consumer_key']) ? $instance['twitter_consumer_key'] : '';
     $twitter_consumer_secret = isset($instance['twitter_consumer_secret']) ? $instance['twitter_consumer_secret'] : '';
     $twitter_token_key = isset($instance['twitter_token_key']) ? $instance['twitter_token_key'] : '';
     $twitter_token_secret = isset($instance['twitter_token_secret']) ? $instance['twitter_token_secret'] : '';
     $twitter_count = isset($instance['twitter_count']) ? $instance['twitter_count'] : '';
     if (empty($twitter_consumer_key) || empty($twitter_consumer_secret) || empty($twitter_token_key) || empty($twitter_token_secret)) {
         return;
     }
     $data = getTwitterData(array('mode' => 'user_timeline', 'consumer_key' => $twitter_consumer_key, 'consumer_secret' => $twitter_consumer_secret, 'token' => $twitter_token_key, 'secret' => $twitter_token_secret));
     if (!$data || !isset($data[0]['text'])) {
         return;
     }
     $output = '<ul>';
     $cnt = 0;
     foreach ($data as $tweet) {
         $tweet_date = $tweet['created_at'];
         $date_diff = '<span class="tweet_date"><i class="icon-clock-1"></i>' . getDateOrDifference($tweet_date) . '</span>';
         if (themerex_substr($tweet['text'], 0, 1) == '@') {
             continue;
         }
         $output .= '<li class="theme_text' . ($cnt == $twitter_count - 1 ? ' last' : '') . '"><i class="icon-twitter"></i><a href="https://twitter.com/' . $twitter_username . '" class="username" target="_blank">@' . $tweet['user']['screen_name'] . '</a> ' . twitter_prepare_text($tweet) . $date_diff . '</li>';
         if (++$cnt >= $twitter_count) {
             break;
         }
     }
     $output .= '</ul>';
     if (!empty($output)) {
         /* Before widget (defined by themes). */
         echo $before_widget;
         /* Display the widget title if one was input (before and after defined by themes). */
         echo $before_title . $title . $after_title;
         echo $output;
         /* After widget (defined by themes). */
         echo $after_widget;
     }
 }
Esempio n. 2
0
function getTwitterFollowers($cfg)
{
    $data = getTwitterData($cfg);
    return $data && isset($data[0]['user']['followers_count']) ? $data[0]['user']['followers_count'] : 0;
}
Esempio n. 3
0
function sc_twitter($atts, $content = null)
{
    if (in_shortcode_blogger()) {
        return '';
    }
    extract(shortcode_atts(array("id" => "", "class" => "", "interval" => "", "count" => "3", "user" => "", "consumer_key" => "", "consumer_secret" => "", "token_key" => "", "token_secret" => "", "width" => "", "height" => "", "top" => "", "bottom" => "", "left" => "", "right" => ""), $atts));
    $s = getStyleString($top, $right, $bottom, $left);
    $d = getStyleString('', '', '', '', $width, $height);
    $twitter_username = $user ? $user : get_theme_option('twitter_username');
    $twitter_consumer_key = $consumer_key ? $consumer_key : get_theme_option('twitter_consumer_key');
    $twitter_consumer_secret = $consumer_secret ? $consumer_secret : get_theme_option('twitter_consumer_secret');
    $twitter_token_key = $token_key ? $token_key : get_theme_option('twitter_token_key');
    $twitter_token_secret = $token_secret ? $token_secret : get_theme_option('twitter_token_secret');
    $twitter_count = max(1, $count ? $count : intval(get_theme_option('twitter_count')));
    $output = '';
    if (!empty($twitter_consumer_key) && !empty($twitter_consumer_secret) && !empty($twitter_token_key) && !empty($twitter_token_secret)) {
        $data = getTwitterData(array('mode' => 'user_timeline', 'consumer_key' => $twitter_consumer_key, 'consumer_secret' => $twitter_consumer_secret, 'token' => $twitter_token_key, 'secret' => $twitter_token_secret));
        if ($data && isset($data[0]['text'])) {
            $output = '
				<div' . ($id ? ' id="' . $id . '"' : '') . ' class="sc_twitter twitBlock' . ($class ? ' ' . $class : '') . '"' . ($s != '' ? ' style="' . $s . '"' : '') . '>
					<div class="sc_slider sc_slider_swiper sc_slider_controls sc_slider_nopagination sc_slider_noresize sc_slider_autoheight swiper-slider-container"' . ((int) $interval > 0 ? ' data-interval="' . $interval . '"' : '') . ($d != '' ? ' style="' . $d . '"' : '') . '>
						<ul class="slides swiper-wrapper">
							';
            $cnt = 0;
            foreach ($data as $tweet) {
                if (themerex_substr($tweet['text'], 0, 1) == '@') {
                    continue;
                }
                $output .= '<li class="sc_twitter_item swiper-slide' . ($cnt == $twitter_count - 1 ? ' last' : '') . '">' . '<p>' . '<span class="twitterIco"></span>' . '<a href="https://twitter.com/' . $twitter_username . '" class="twitAuthor" target="_blank">@' . htmlspecialchars($tweet['user']['screen_name']) . '</a> ' . twitter_prepare_text($tweet) . '</p>' . '</li>';
                if (++$cnt >= $twitter_count) {
                    break;
                }
            }
            $output .= '
						</ul>
						<ul class="flex-direction-nav">
							<li><a class="flex-prev" href="#"></a></li>
							<li><a class="flex-next" href="#"></a></li>
						</ul>
					</div>
				</div>';
        }
    }
    return $output;
}
Esempio n. 4
0
<?php

// 日付データ取得
$date = date("Y-m-d", time());
// 炎上リスト読み込み
$file = '/tmp/people.json';
$people_list = json_decode(file_get_contents($file), true);
// Twitterデータからスコア値を取得
$fire_info = array();
foreach ($people_list as $people) {
    if (empty($people)) {
        continue;
    }
    // パラメータ設定
    $params = array('q' => '炎上 ' . $people['name'], 'count' => '100', 'until' => $date);
    $twitter = getTwitterData($params);
    $score = getScoreData($twitter);
    if (!$score) {
        $score = 0;
    }
    $fire_info[] = array('name' => $people['name'], 'image' => $people['image'], 'score' => $score);
}
// DB情報
define('DB_HOST', 'localhost');
define('DB_NAME', 'fire');
define('DB_USER', 'root');
define('DB_PASSWORD', '');
// 文字化け対策
$options = array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET CHARACTER SET 'utf8'");
// PHPのエラーを表示するように設定
error_reporting(E_ALL & ~E_NOTICE);