Exemple #1
0
    /**
     * Front-end display of widget.
     *
     * @see WP_Widget::widget()
     *
     * @param array $args     Widget arguments.
     * @param array $instance Saved values from database.
     */
    public function widget($args, $instance)
    {
        $title = apply_filters('widget_title', $instance['title']);
        echo $args['before_widget'];
        if (!empty($title)) {
            echo $args['before_title'] . $title . $args['after_title'];
        }
        ?>
		
		<ul>
		<?php 
        if (get_option('tdf_consumer_key') && get_option('tdf_consumer_secret') && get_option('tdf_access_token') && get_option('tdf_access_token_secret')) {
            $tweets = getTweets($instance['username'], $instance['tweets']);
            foreach ($tweets as $tweet) {
                echo '<li>' . TwitterFilter($tweet['text']) . '</li>';
            }
        } else {
            echo '<li>Twitter Feed not configured. <a href="' . admin_url('options-general.php?page=tdf_settings') . '">Click here to edit.</a></li>';
        }
        ?>
		</ul>

		<?php 
        echo $args['after_widget'];
    }
    protected function content($atts, $content = null)
    {
        extract(shortcode_atts(array('username' => 'avathemes', 'feed_num' => '8'), $atts));
        // $width_class = '';
        // $css_class = apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $width_class, $this->settings['base'], $atts );
        ob_start();
        $tweets = getTweets(intval($feed_num), $username);
        ?>

		<?php 
        if (is_array($tweets)) {
            echo "<div class='twitter_feed_wraper'>";
            foreach ($tweets as $tweet) {
                $the_tweet = $tweet['text'];
                if (is_array($tweet['entities']['urls'])) {
                    foreach ($tweet['entities']['urls'] as $key => $link) {
                        $the_tweet = preg_replace('`' . $link['url'] . '`', '<a href="' . $link['url'] . '" target="_blank">' . $link['url'] . '</a>', $the_tweet);
                    }
                }
                echo '<div class="feed_holder match-me-no-row"><i class="fa fa-twitter"></i> &nbsp; ' . $the_tweet . '</div>';
            }
            echo "</div>";
        }
        ?>

		<?php 
        $output = ob_get_contents();
        ob_end_clean();
        return $output;
    }
 /**
  * Front-end display of widget.
  *
  * @see WP_Widget::widget()
  *
  * @param array $args     Widget arguments.
  * @param array $instance Saved values from database.
  */
 public function widget($args, $instance)
 {
     echo wp_kses($args['before_widget'], array("div" => array("class" => array(), "id" => array())));
     if (!empty($instance['title'])) {
         echo wp_kses($args['before_title'], array("h3" => array("class" => array(), "id" => array()))) . apply_filters('widget_title', $instance['title']) . wp_kses($args['after_title'], array("h3" => array("class" => array(), "id" => array())));
     }
     if (function_exists('getTweets')) {
         $tweets_num = $instance['tweet_num'];
         $user = $instance['username'];
         $tweets = getTweets($user, $tweets_num);
         if (is_array($tweets)) {
             foreach ($tweets as $tweet) {
                 if ($tweet['text']) {
                     $the_tweet = $tweet['text'];
                     if (is_array($tweet['entities']['urls'])) {
                         foreach ($tweet['entities']['urls'] as $key => $link) {
                             $the_tweet = preg_replace('`' . $link['url'] . '`', '<a href="' . $link['url'] . '" target="_blank">' . $link['url'] . '</a>', $the_tweet);
                         }
                     }
                     echo "<div class='tweet_holder'><i class='fa fa-twitter'></i>" . $the_tweet . "</div>";
                 }
             }
         }
     }
     echo wp_kses($args['after_widget'], array("div" => array("class" => array(), "id" => array())));
 }
Exemple #4
0
 function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     $username = $instance['username'];
     echo $before_widget;
     echo $before_title . $title . $after_title;
     echo '<div id="twitter_wrapper"><div id="twitter_user" class="hidden">' . $username . '</div><div id="twitter"><ul class="post-list">';
     $tweets = getTweets(2, $username);
     foreach ($tweets as $tweet) {
         echo '<li>' . rbTwitterFilter($tweet['text']) . '</li>';
     }
     echo '</ul></div><span class="username"><a href="http://twitter.com/' . $username . '">&rarr; Follow @' . $username . '</a></span></div>';
     echo $after_widget;
 }
Exemple #5
0
function search($term)
{
    global $name, $path, $TweetsPulled, $TweetsAnalyzed, $tweets;
    $name = $term;
    $path = "Cache Files/cache" . $name . ".txt";
    $id = getID($name);
    $pic = getProfilePic($id, $name);
    $max_id = getNextID($path);
    //gets next tweet to cache, creates file if new cache to be made
    $tweets = getTweets($name, $id, $TweetsPulled, $max_id);
    if (!isset($tweets) || count($tweets) < 1) {
        echo "<script> alert('Bad Twitter Handle'); </script>";
        return;
    }
    $res = parseData($tweets, $TweetsAnalyzed);
}
 function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     echo $before_widget;
     echo $before_title . $title . $after_title;
     $replies = $instance['replies'] != 'true' ? 'false' : 'true';
     $opts = array("exclude_replies" => $replies);
     if (function_exists('getTweets')) {
         echo '<ul class="list_tweets' . '-' . $this->number . '">';
         $tweets = getTweets($instance['username'], $instance['limit'], $opts);
         if (is_array($tweets)) {
             foreach ($tweets as $tweet) {
                 if ($tweet['text']) {
                     $the_tweet = $tweet['text'];
                     if (is_array($tweet['entities']['user_mentions'])) {
                         foreach ($tweet['entities']['user_mentions'] as $key => $user_mention) {
                             $the_tweet = preg_replace('/@' . $user_mention['screen_name'] . '/i', '<a href="http://www.twitter.com/' . $user_mention['screen_name'] . '" target="_blank">@' . $user_mention['screen_name'] . '</a>', $the_tweet);
                         }
                     }
                     if (is_array($tweet['entities']['hashtags'])) {
                         foreach ($tweet['entities']['hashtags'] as $key => $hashtag) {
                             $the_tweet = preg_replace('/#' . $hashtag['text'] . '/i', '<a href="https://twitter.com/search?q=%23' . $hashtag['text'] . '&amp;src=hash" target="_blank">#' . $hashtag['text'] . '</a>', $the_tweet);
                         }
                     }
                     if (is_array($tweet['entities']['urls'])) {
                         foreach ($tweet['entities']['urls'] as $key => $link) {
                             $the_tweet = preg_replace('`' . $link['url'] . '`', '<a href="' . $link['url'] . '" target="_blank">' . $link['url'] . '</a>', $the_tweet);
                         }
                     }
                     echo '<li>';
                     echo '<span class="tweet_text">';
                     echo $the_tweet;
                     echo '</span>';
                     echo '<span class="tweet_timestamp"><a href="https://twitter.com/' . $instance['username'] . '/status/' . $tweet['id_str'] . '" target="_blank">' . date('h:i A M d', strtotime($tweet['created_at'] . '- 8 hours')) . '</a></span>';
                     echo '</li>';
                 }
             }
         }
         echo '</ul>';
     } else {
         echo '<span>Please install <a href="http://wordpress.org/plugins/oauth-twitter-feed-for-developers/">oAuth Twitter Feed for Developers</a> plugin</span>';
     }
     echo $after_widget;
 }
 function add_to_context($context)
 {
     $context['foo'] = 'bar';
     $context['stuff'] = 'I am a value set in your functions.php file';
     $context['notes'] = 'These values are available everytime you call Timber::get_context();';
     //$context['menu'] = new TimberMenu();
     $context['menu'] = new TimberMenu(wp_nav_menu(array('menu' => 'primary', 'theme_location' => 'primary', 'depth' => 4, 'container' => 'div', 'container_class' => 'collapse navbar-collapse no_padding_left', 'container_id' => 'bs-example-navbar-collapse-1', 'menu_class' => 'nav navbar-nav', 'fallback_cb' => 'wp_bootstrap_navwalker::fallback', 'walker' => new wp_bootstrap_navwalker())));
     //$data['menu_2'] = wp_nav_menu( $menu_array);
     //$context['menu'] = new TimberMenu($my_dynamic_menu);
     //  $context['primary_menu'] = new TimberMenu('primary-menu');
     $context['site'] = $this;
     /*
      *  Header Image
      */
     $context['site_logo'] = get_option('upload_image');
     $context['menu_upload_image'] = get_option('menu_upload_image');
     /*
      *  Footer 
      */
     $context['footer_tag_line'] = get_option('footer_text');
     $context['footer_address'] = get_option('address');
     $context['footer_site_url'] = site_url();
     $context['footer_inquiry_mail'] = get_option('inquiry_mail');
     $context['footer_telephone'] = get_option('telephone');
     $context['s_facebook'] = get_option('facebook');
     $context['s_twitter'] = get_option('twitter');
     $context['s_linkedin'] = get_option('linkedin');
     $context['footer_copyright'] = get_option('copyright');
     $context['footer_contact_form'] = '[contact-form-7 id="30" title="Contact form 1"]';
     /*
      *  Twitter
      */
     $context['get_twiiter_url'] = get_option('twitter');
     $context['get_twitter_username'] = get_option('tdf_user_timeline');
     $context['get_tweeter_no_to_display'] = get_option('twitter_post_to_display');
     $context['get_tweeter_no_to_display'] = (int) get_option('get_tweeter_no_to_display');
     $context['tweets'] = getTweets('get_tweeter_no_to_display');
     //change number up to 20 for number of tweets
     //                                    echo "<pre>";
     //                                    print_r($context);
     //                                    echo "</pre>";
     return $context;
 }
Exemple #8
0
function getTweets($hash_tag, $page)
{
    global $total, $hashtag;
    $url = 'http://search.twitter.com/search.json?q=' . urlencode($hash_tag) . '&';
    $url .= 'page=' . $page;
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    $json = curl_exec($ch);
    curl_close($ch);
    //echo "<pre>";
    //$json_decode = json_decode($json);
    //print_r($json_decode->results);
    $json_decode = json_decode($json);
    $total += count($json_decode->results);
    if ($json_decode->next_page) {
        $temp = explode("&", $json_decode->next_page);
        $p = explode("=", $temp[0]);
        getTweets($hashtag, $p[1]);
    }
}
    public function handleShortcode($atts, $content = null)
    {
        extract(shortcode_atts(array('id' => rand(1, 9999), 'usr' => 'aplusk', 'nr' => '2', 'oat' => '2403135363-ldFj7vdqJ4sb4moanZQgQwMLZoHhY4fNeSW06Em', 'oats' => 'rwpjO4sZcPKKCE9ZU07HiqTLYZYK9B2UODpAIjFOFBM1u', 'ck' => 'nABhqKv75G5JNSwsYlSjsNAKf', 'cks' => 'ZkHjLITRh74QZfLZI64yxXLheYLxF45j5Be9s3iHuP2ds2wV38', 'color' => '#bdc3c7', 'text_color' => '#313131', 'link_color' => '#999', 'linkh_color' => ot_get_option('coll_accent_color'), 'class' => ''), $atts));
        $output = '';
        $output .= '<div class="coll-twitter ' . $class . '"
                    data-coll-color=\'{ "m":"' . $color . '",
                                        "t":"' . $text_color . '",
                                        "l":"' . $link_color . '",
                                        "lh":"' . $linkh_color . '"}\';
                    >';
        $output .= '<ul class="logo">';
        $output .= '<li class="left"></li>';
        $output .= '<li class="center"><i class="fa fa-twitter"></i></li>';
        $output .= '<li class="right"></li>';
        $output .= '</ul>';
        $output .= '<div id="twitter-' . $id . '"class="tweets-slider coll-flexslider flexslider" >';
        $output .= '<script type="text/javascript">
                jQuery(document).ready(function($){
                        $("#twitter-' . $id . ' .slides").html(format_tweets(' . getTweets($usr, $nr, $oat, $oats, $ck, $cks) . '));
                });
                </script>';
        $output .= '<script type="text/javascript">
                jQuery(document).ready(function ($) {
                    $(window).load(function() {
                        var _slider = $("#twitter-' . $id . '")

                       _slider.flexslider({
                            start: function(slider){

                                _slider.find(".flex-control-nav > li > a")
                                    .css("border-color",  \'' . $color . '\')
                                    .hover (
                                        function(){
                                        $(this).css("background-color", "' . $color . '")
                                        },
                                        function(){
                                         $(this).css("background-color", "transparent")
                                        })
		                        _slider.find(".flex-control-nav > li > a.flex-active")
                                    .css("background-color", "' . $color . '")
                                _slider.find(".flex-direction-nav > li > a")
                                    .css("border-color",  \'' . $color . '\')
                                    .css("color",  \'' . $color . '\')
                                    .hover (
                                        function(){
                                        //$(this).css("background", "none")
                                        $(this).css("background-color", "' . $color . '")
                                        },
                                        function(){
                                         $(this).css("background-color", "transparent")
                                        })

                                    _slider.trigger("coll.flexslider.init");
                            },
                            before: function(_slider){
                                _slider.find(".flex-control-nav > li > a.flex-active")
                                     .css("background-color", "transparent")
                            },
                            after: function(_slider){
                                _slider.find(".flex-control-nav > li > a.flex-active")
                                    .css("background-color", "' . $color . '")
                                $(window).trigger("resize");
                            }
                        });

                    });
                });
                </script>';
        $output .= '<ul class="slides">';
        $output .= '</ul>';
        $output .= '</div>';
        $output .= '</div>';
        return $output;
    }
Exemple #10
0
    $twitterInfo = $twitterObj->get_accountVerify_credentials();
    $twitterInfo->response;
    $username = $twitterInfo->screen_name;
    $profilepic = $twitterInfo->profile_image_url;
    echo "<div class='left_col'>";
    echo "<div id='divWelcome' align='center'>Logged in as " . $username;
    echo "<br><img src={$profilepic} title='Profile Picture'></div>";
    echo "</div>";
    //Left col div ends
    echo "<div class='right_col'>";
    echo "<h2>Twitter Timeline Challnege</h2>";
    //Include tweet page which contains tweet grabbing code
    include 'tweet.php';
    echo "Tweet Showcase:";
    echo "<div id='divTweetContainer' class='slideshowTweet'>";
    getTweets($username, 'tweet');
    echo "</div>";
    //Include follower page which contains followers grabbing code
    include 'follower.php';
    getFollo($username);
    echo "</div>";
    //Right col div ends
}
echo "</div>";
// Container div ends
?>

<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Exemple #11
0
<?php

if (!isset($_POST['say'])) {
    die('Holy Jehosaphat!');
}
require_once 'includes/cleantweet.php';
require_once 'includes/db.inc.php';
if (bannedIP($_SERVER['REMOTE_ADDR'])) {
    die;
}
$err = '';
$stat = cleantweet($_POST['say']);
$last = getTweets(1);
if (strlen($stat) > 140) {
    $err = 'That was longer than 140 characters!';
} elseif ($stat == 'Say something in 140 characters.' || $stat == '') {
    $err = 'Umm... You didn\'t exactly say anything...';
} elseif (!validTimestamp($_POST['submit'])) {
    $err = 'Whoa! Something weird just happened. Try again, I guess? (Debug ' . intval($_POST['submit']) . ')';
} elseif (bannedTweet($stat)) {
    $err = 'Sorry, I just can\'t post that.';
}
if ($err == '') {
    require_once 'includes/twitter.inc.php';
    $tw = new Twitter('ub3rk1ttencom', 'oopsiesthisgotleaksied');
    $rets = false;
    $exc = false;
    try {
        $ret = $tw->updateStatus(stripslashes($stat));
        $rets = $ret['id'];
    } catch (TwitterException $ex) {
Exemple #12
0
<?php

function getTweets($hash_tag)
{
    $url = 'http://search.twitter.com/search.json?q=' . urlencode($hash_tag) . "&include_entities=true";
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    $json = curl_exec($ch);
    curl_close($ch);
    return $json;
}
$a1 = json_decode(getTweets('#SpyderOOODay'), true);
$a2 = json_decode(getTweets('#GoodbyeEatStreet'), true);
$a3 = json_decode(getTweets('#HelloLoringCorners'), true);
$html = "<ul id=\"filter-tweet\">\n";
foreach ($a1[results] as $a) {
    $html .= "<li class=\"spydertrapoooday\">\n";
    if (!empty($a['entities']['media'][0]['media_url'])) {
        $html .= sprintf("<img src=\"%s\" /><br />\n", $a['entities']['media'][0]['media_url']);
    }
    $html .= sprintf("<a href=\"http://www.twitter.com/%s\"><img src=\"%s\" /></a>\n", $a['from_user'], $a['profile_image_url']);
    $html .= sprintf("%s", $a['text']);
    $html .= "</li>\n";
}
foreach ($a2[results] as $a) {
    $html .= "<li class=\"goodbyeeatstreet\">\n";
    if (!empty($a['entities']['media'][0]['media_url'])) {
        $html .= sprintf("<img src=\"%s\" /><br />\n", $a['entities']['media'][0]['media_url']);
    }
    $html .= sprintf("<a href=\"http://www.twitter.com/%s\"><img src=\"%s\" /></a>\n", $a['from_user'], $a['profile_image_url']);
    $html .= sprintf("%s", $a['text']);
Exemple #13
0
<?php

$tweets = getTweets(1, 'TattonIM', array("exclude_replies" => true));
//var_dump($tweets);
foreach ($tweets as $tweet) {
    //var_dump($tweet['text']);
    ?>
<section class="twitter-block">
    <div class="container">
        <div class="row">
            <div class="col-xs-12 col-sm-10 col-sm-offset-1 pt-lg pb-lg text-center">
				<div class="twitter-block__icon twitter"></div>
				<p class="twitter-block__tweet mt-md"><?php 
    echo $tweet['text'];
    ?>
</p>
            	<p><a class="more" href="<?php 
    the_field('social_twitter', 'option');
    ?>
">More Twitter</a></p>
            </div>
        </div>
    </div>
</section> 	
<?php 
}
<?php

extract(shortcode_atts(array('class' => '', 'id' => '', 'css_animation' => '', 'css_animation_delay' => '', 'carousel' => '', 'color' => '', 'user' => '', 'tweets' => '', 'carousel_style' => ''), $atts));
$animated = $css_animation ? 'animate' : '';
$css_animation_delay = $css_animation ? ' data-delay="' . $css_animation_delay . '"' : '';
$class = setClass(array('md-tweets', $animated, $css_animation, $class, $carousel));
$id = setId($id);
$uniqid = 'md-tweets-' . uniqid();
if (get_option('tdf_consumer_key') && get_option('tdf_consumer_secret') && get_option('tdf_access_token') && get_option('tdf_access_token_secret')) {
    $output .= '<div' . $class . $id . $css_animation_delay . '>';
    $output .= '<div class="twitter-logo"><a href="http://twitter.com/' . $user . '" target="_blank" style="color:' . $color . '"><i class="icon-twitter"></i></a></div>';
    $output .= '<div class="md-carousel ' . $carousel_style . '" data-items="1" data-items-tablet="1" data-items-mobile="1" data-autoplay="true" data-pagination="true" data-navigation="false" id="' . $uniqid . '">';
    $tweets = getTweets($user, $tweets);
    foreach ($tweets as $tweet) {
        $output .= '
                    <div class="md-tweet item" style="color:' . $color . '">
                        <div class="tweet-content">
                            <div class="tweet-text">' . TwitterFilter($tweet['text']) . '</div>
                        </div>
                        <div class="tweet-info">
                            <span class="tweet-time"><a href="' . 'https://twitter.com/' . $user . '/status/' . $tweet['id_str'] . '" target="_blank" style="color:' . $color . '">' . date('j F o \\a\\t g:i A', strtotime($tweet['created_at'])) . '</a></span>
                        </div>
                    </div>';
    }
    $output .= '</div>';
    $output .= '</div>';
    $output .= '<style type="text/css">#' . $uniqid . ' .md-tweet a{color:' . $color . ';}</style>';
} else {
    $output = '<span style="color:' . $color . '">Twitter Feed not configured. <a href="' . admin_url('options-general.php?page=tdf_settings') . '" style="color:' . $color . '">Click here to edit.</a></span>';
}
echo $output;
Exemple #15
0
 function brad_get_tweets($count, $twitterID)
 {
     $content = "";
     if ($twitterID == "") {
         return __("Please provide your Twitter username", "brad");
     }
     if (function_exists('getTweets')) {
         $options = array('trim_user' => true, 'exclude_replies' => false, 'include_rts' => false);
         $tweets = getTweets($twitterID, $count, $options);
         $content .= '<div class="recent-tweets" id="recent_tweets_' . rand() . '"><ul>';
         if (is_array($tweets)) {
             foreach ($tweets as $tweet) {
                 $content .= '<li>';
                 if (is_array($tweet) && $tweet['text']) {
                     $content .= '<span>';
                     $the_tweet = $tweet['text'];
                     if (is_array($tweet['entities']['user_mentions'])) {
                         foreach ($tweet['entities']['user_mentions'] as $key => $user_mention) {
                             $the_tweet = preg_replace('/@' . $user_mention['screen_name'] . '/i', '<a href="http://www.twitter.com/' . $user_mention['screen_name'] . '" target="_blank">@' . $user_mention['screen_name'] . '</a>', $the_tweet);
                         }
                     }
                     // ii. Hashtags must link to a twitter.com search with the hashtag as the query.
                     if (is_array($tweet['entities']['hashtags'])) {
                         foreach ($tweet['entities']['hashtags'] as $key => $hashtag) {
                             $the_tweet = preg_replace('/#' . $hashtag['text'] . '/i', '<a href="https://twitter.com/search?q=%23' . $hashtag['text'] . '&amp;src=hash" target="_blank">#' . $hashtag['text'] . '</a>', $the_tweet);
                         }
                     }
                     // iii. Links in Tweet text must be displayed using the display_url
                     //      field in the URL entities API response, and link to the original t.co url field.
                     if (is_array($tweet['entities']['urls'])) {
                         foreach ($tweet['entities']['urls'] as $key => $link) {
                             $the_tweet = preg_replace('`' . $link['url'] . '`', '<a href="' . $link['url'] . '" target="_blank">' . $link['url'] . '</a>', $the_tweet);
                         }
                     }
                     // Custom code to link to media
                     if (isset($tweet['entities']['media']) && is_array($tweet['entities']['media'])) {
                         foreach ($tweet['entities']['media'] as $key => $media) {
                             $the_tweet = preg_replace('`' . $media['url'] . '`', '<a href="' . $media['url'] . '" target="_blank">' . $media['url'] . '</a>', $the_tweet);
                         }
                     }
                     $content .= $the_tweet;
                     $content .= '</span>';
                     $date = strtotime($tweet['created_at']);
                     // retrives the tweets date and time in Unix Epoch terms
                     $blogtime = current_time('U');
                     // retrives the current browser client date and time in Unix Epoch terms
                     $dago = human_time_diff($date, $blogtime) . ' ' . sprintf(__('ago', 'brad'));
                     // calculates and outputs the time past in human readable format
                     $content .= '<br /><a class="timestamp" href="https://twitter.com/' . $twitterID . '/status/' . $tweet['id_str'] . '" target="_blank">' . $dago . '</a>' . "\n";
                 } else {
                     $content .= '<br /><a href="http://twitter.com/' . $twitterID . '" target="_blank">@' . $twitterID . '</a>';
                 }
                 $content .= '</li>';
             }
         }
         $content .= '</ul></div>';
         return $content;
     } else {
         return 'Please install the oAuth Twitter Feed Plugin';
     }
 }
if ($twitter_mode == "one_tweet") {
    $tweet_id = 'twitter-feed';
} else {
    $tweet_id = 'twitter-feed';
}
$class = setClass(array('tweet_list', $el_class, $twitter_slides_class, $animation_loading_class, $animation_effect_class, $responsive_lg, $responsive_md, $responsive_sm, $responsive_xs));
$output .= '<div id="' . $tweet_id . '">
			<ul' . $class . '' . $animation_delay_class . '>';
if ($twitter_mode == "one_tweet") {
    $num_tweet = 1;
    $tweets = getTweets($num_tweet, $twitter_username);
    foreach ($tweets as $tweet) {
        $output .= '
				<li>
					<span class="tweet_text">' . TwitterFilter($tweet['text']) . '</span>
					<span class="tweet_time"><a href="https://twitter.com/' . $twitter_username . '/status/' . $tweet['id_str'] . '">' . date('j F o \\a\\t g:i A', strtotime($tweet['created_at'])) . '</a></span>
				</li>';
    }
} else {
    $tweets = getTweets(intval($num_tweet), $twitter_username);
    foreach ($tweets as $tweet) {
        $output .= '
				<li>
					<span class="tweet_text">' . TwitterFilter($tweet['text']) . '</span>
					<span class="tweet_time"><a href="https://twitter.com/' . $twitter_username . '/status/' . $tweet['id_str'] . '">' . date('j F o \\a\\t g:i A', strtotime($tweet['created_at'])) . '</a></span>
				</li>';
    }
}
$output .= '</ul>
			</div>';
echo $output . $this->endBlockComment('az_big_twitter_feed');
<?php

$output = $el_class = $twitter_feed_colors = $twitter_feed_type = $tweets_total = $twitter_username = '';
extract(shortcode_atts(array('twitter_feed_colors' => 'dark-mode', 'twitter_feed_type' => 'slide', 'twitter_username' => 'bluxart', 'tweets_total' => '1', 'el_class' => ''), $atts));
$el_class = $this->getExtraClass($el_class);
// Get Uniq Id
$uniq_self = uniqid();
$css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, 'az-twitter-feed' . $el_class, $this->settings['base']);
$class = setClass(array('flexslider', $css_class, $twitter_feed_colors));
$output .= '
<div id="twitter-feed-section-' . $uniq_self . '"' . $class . ' data-slide-type="' . $twitter_feed_type . '" data-slide-easing="swing" data-slide-loop="false" data-slideshow="false">
	<ul class="slides">';
if (function_exists('getTweets')) {
    $tweets = getTweets(intval($tweets_total), $twitter_username);
    foreach ($tweets as $tweet) {
        $output .= '
		<li class="twitter-feed-item slide">
			<div class="twitter-wrap">
				<span class="tweet_text">' . TwitterFilter($tweet['text']) . '</span>
			</div>
		</li>';
    }
} else {
    $output .= '
		<li class="error">Please install the <a href="http://wordpress.org/plugins/oauth-twitter-feed-for-developers/">oAuth Twitter Feed Plugin</a> and configure it properly for the twitter widget to run. Read more about this in the manual.</li>';
}
$output .= '
	</ul>
</div>';
echo $output . $this->endBlockComment('az_twitter_feed');
Exemple #18
0
<?php

// Source : http://www.inkplant.com/code/get-twitter-posts-by-hashtag.php
function getTweets($hash_tag)
{
    $url = 'http://search.twitter.com/search.atom?q=' . urlencode($hash_tag);
    echo "<p>Connecting to <strong>{$url}</strong> ...</p>";
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    $xml = curl_exec($ch);
    curl_close($ch);
    //If you want to see the response from Twitter, uncomment this next part out:
    //echo "<p>Response:</p>";
    //echo "<pre>".htmlspecialchars($xml)."</pre>";
    $affected = 0;
    $twelement = new SimpleXMLElement($xml);
    foreach ($twelement->entry as $entry) {
        $text = trim($entry->title);
        $author = trim($entry->author->name);
        $time = strtotime($entry->published);
        $id = $entry->id;
        echo "<p>Tweet from " . $author . ": <strong>" . $text . "</strong>  <em>Posted " . date('n/j/y g:i a', $time) . "</em></p>";
    }
    return true;
}
getTweets('#php');
$root = $doc->createElement('results');
$root = $doc->appendChild($root);
$limitString = '';
if ($limit > 0) {
    $limitString .= "LIMIT " . $offset . ", " . $limit;
}
$result = mysql_query("SELECT * FROM newswire_tb WHERE (createdTime >= '" . $date . "' AND createdTime < '" . $date . "' + INTERVAL 24 HOUR) ORDER BY createdTime ASC " . $limitString);
$totalNewsitems = 0;
while ($row = mysql_fetch_assoc($result)) {
    //echo $row['updatedTime'];
    $newsNode = $doc->createElement('news_item');
    //$root->appendChild( $newsNode );
    appendNewsNodeItems($newsNode, $row);
    $tweetNode = $doc->createElement('tweets');
    $newsNode->appendChild($tweetNode);
    $totalTweets = getTweets($row, $tweetNode);
    if ($totalTweets >= $minTweets) {
        $root->appendChild($newsNode);
        $totalNewsitems += 1;
    }
}
appendAttribute($doc, $root, 'totalNewsItems', strval($totalNewsitems));
echo $xml_string = $doc->saveXML();
////////////////////////////////////////////////////////////////////////////////////
function getTweets($newsitem, $parentNode)
{
    global $doc, $root, $minTweets;
    $newsitem_id = $newsitem["id"];
    $newsitem_time = strtotime($newsitem['createdTime']);
    $result = mysql_query("SELECT * FROM backtweets_db WHERE newswire_id=" . $newsitem_id . " ORDER BY tweet_id ASC");
    $totalTweets = mysql_num_rows($result);
    } else {
        $usernameText = "@" . $username;
    }
    // Print the twitter username
    echo $usernameText;
    echo "</div>";
    // Print the tweet text
    echo $tweet['text'];
    if (isset($tweet['entities']['media'])) {
        echo "<img src='" . $tweet['entities']['media'][0]['media_url'] . ":thumb' alt='' width='150'>";
    }
    // Print the time of the tweet
    echo "<div class='time'>" . $tweet['created_at'] . "</div>";
    echo "</div>";
}
getTweets('#daretodo');
?>
<html>
<head>
  <title>My Twitter Feed App</title>
  <style>
    #stem-twitter {
      width: 80%;
      font-family: arial, "Helvetica Neue", Helvetica;
      font-size: 12px;
      color: #333333;
      padding: 10px;
      margin:0 auto;
    }

    #stem-twitter .tweet {
include_once $_SERVER['DOCUMENT_ROOT'] . '/includes/functions.php';
if (isset($_POST['username'], $_POST['p']) && $_POST['form_type'] == "login") {
    include_once $_SERVER['DOCUMENT_ROOT'] . '/includes/process_login.php';
}
if (!isset($_SESSION)) {
    session_start();
    //sec_session_start();
}
$tweets = null;
if (login_check($mysqli) == true) {
    $logged_in = true;
    //load user permissions and data
    include_once $_SERVER['DOCUMENT_ROOT'] . '/includes/user_profile.php';
    //prepare tweets
    include_once $_SERVER['DOCUMENT_ROOT'] . '/includes/twitterAPI.php';
    $tweets = getTweets("crabs");
    //prepare user content
    $user_content = get_published_content($mysqli);
} else {
    $logged_in = false;
}
?>

<!DOCTYPE html>
<html>
  <head>
    <title>Crab News, Forums & Games - Crabtown: The Official World of Crabs</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    
    <link rel="stylesheet" type="text/css" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
Exemple #22
0
 function sf_latest_tweet($count, $twitterID)
 {
     global $sf_include_twitter;
     $sf_include_twitter = true;
     $content = "";
     if ($twitterID == "") {
         return __("Please provide your Twitter username", "swiftframework");
     }
     if (function_exists('getTweets')) {
         $options = array('trim_user' => true, 'exclude_replies' => false, 'include_rts' => false);
         $tweets = getTweets($twitterID, $count, $options);
         if (is_array($tweets)) {
             foreach ($tweets as $tweet) {
                 $content .= '<li>';
                 if (is_array($tweet) && isset($tweet['text']) && $tweet['text']) {
                     $content .= '<div class="tweet-text">';
                     $the_tweet = $tweet['text'];
                     /*  for PRO users! - 
                     				        Twitter Developer Display Requirements
                     				        https://dev.twitter.com/terms/display-requirements
                     				
                     				        2.b. Tweet Entities within the Tweet text must be properly linked to their appropriate home on Twitter. For example:
                     				          i. User_mentions must link to the mentioned user's profile.
                     				         ii. Hashtags must link to a twitter.com search with the hashtag as the query.
                     				        iii. Links in Tweet text must be displayed using the display_url
                     				             field in the URL entities API response, and link to the original t.co url field.
                     				        */
                     // i. User_mentions must link to the mentioned user's profile.
                     if (isset($tweet['entities']['user_mentions']) && is_array($tweet['entities']['user_mentions'])) {
                         foreach ($tweet['entities']['user_mentions'] as $key => $user_mention) {
                             $the_tweet = preg_replace('/@' . $user_mention['screen_name'] . '/i', '<a href="http://www.twitter.com/' . $user_mention['screen_name'] . '" target="_blank">@' . $user_mention['screen_name'] . '</a>', $the_tweet);
                         }
                     }
                     // ii. Hashtags must link to a twitter.com search with the hashtag as the query.
                     if (isset($tweet['entities']['hashtags']) && is_array($tweet['entities']['hashtags'])) {
                         foreach ($tweet['entities']['hashtags'] as $key => $hashtag) {
                             $the_tweet = preg_replace('/#' . $hashtag['text'] . '/i', '<a href="https://twitter.com/search?q=%23' . $hashtag['text'] . '&amp;src=hash" target="_blank">#' . $hashtag['text'] . '</a>', $the_tweet);
                         }
                     }
                     // iii. Links in Tweet text must be displayed using the display_url
                     //      field in the URL entities API response, and link to the original t.co url field.
                     if (isset($tweet['entities']['urls']) && is_array($tweet['entities']['urls'])) {
                         foreach ($tweet['entities']['urls'] as $key => $link) {
                             $the_tweet = preg_replace('`' . $link['url'] . '`', '<a href="' . $link['url'] . '" target="_blank">' . $link['url'] . '</a>', $the_tweet);
                         }
                     }
                     // Custom code to link to media
                     if (isset($tweet['entities']['media']) && is_array($tweet['entities']['media'])) {
                         foreach ($tweet['entities']['media'] as $key => $media) {
                             $the_tweet = preg_replace('`' . $media['url'] . '`', '<a href="' . $media['url'] . '" target="_blank">' . $media['url'] . '</a>', $the_tweet);
                         }
                     }
                     $content .= $the_tweet;
                     $content .= '</div>';
                     // 3. Tweet Actions
                     //    Reply, Retweet, and Favorite action icons must always be visible for the user to interact with the Tweet. These actions must be implemented using Web Intents or with the authenticated Twitter API.
                     //    No other social or 3rd party actions similar to Follow, Reply, Retweet and Favorite may be attached to a Tweet.
                     // 4. Tweet Timestamp
                     //    The Tweet timestamp must always be visible and include the time and date. e.g., "3:00 PM - 31 May 12".
                     // 5. Tweet Permalink
                     //    The Tweet timestamp must always be linked to the Tweet permalink.
                     $content .= '<div class="twitter_intents">' . "\n";
                     $content .= '<a class="reply" href="https://twitter.com/intent/tweet?in_reply_to=' . $tweet['id_str'] . '"><i class="fa-reply"></i></a>' . "\n";
                     $content .= '<a class="retweet" href="https://twitter.com/intent/retweet?tweet_id=' . $tweet['id_str'] . '"><i class="fa-retweet"></i></a>' . "\n";
                     $content .= '<a class="favorite" href="https://twitter.com/intent/favorite?tweet_id=' . $tweet['id_str'] . '"><i class="fa-star"></i></a>' . "\n";
                     $date = strtotime($tweet['created_at']);
                     // retrives the tweets date and time in Unix Epoch terms
                     $blogtime = current_time('U');
                     // retrives the current browser client date and time in Unix Epoch terms
                     $dago = human_time_diff($date, $blogtime) . ' ' . sprintf(__('ago', 'swiftframework'));
                     // calculates and outputs the time past in human readable format
                     $content .= '<a class="timestamp" href="https://twitter.com/' . $twitterID . '/status/' . $tweet['id_str'] . '" target="_blank">' . $dago . '</a>' . "\n";
                     $content .= '</div>' . "\n";
                 } else {
                     $content .= '<a href="http://twitter.com/' . $twitterID . '" target="_blank">@' . $twitterID . '</a>';
                 }
                 $content .= '</li>';
             }
         }
         return $content;
     } else {
         return '<li><div class="tweet-text">Please install the oAuth Twitter Feed Plugin and follow the theme documentation to set it up.</div></li>';
     }
 }
    return true;
    sleep(1);
}
getTweets('#repidee13');
function getTweets($hash_tag)
{
    /*$url = 'http://search.twitter.com/search.json?q=%s&geocode=%s&rpp=%s&lang=%s&page=%s' \
      % (urllib2.quote(QUERY), urllib2.quote(GEOINFO), RESULTS_PER_PAGE, LANGUAGE, page);*/
    $url = 'http://search.twitter.com/search.atom?s=repidee13';
    echo "<p>Connecting to <strong>{$url}</strong> ...</p>";
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    $xml = curl_exec($ch);
    curl_close($ch);
    //If you want to see the response from Twitter, uncomment this next part out:
    //echo "<p>Response:</p>";
    //echo "<pre>".htmlspecialchars($xml)."</pre>";
    $affected = 0;
    $twelement = new SimpleXMLElement($xml);
    foreach ($twelement->entry as $entry) {
        $text = trim($entry->title);
        $author = trim($entry->author->name);
        $time = strtotime($entry->published);
        $id = $entry->id;
        echo "<p>Tweet from " . $author . ": <strong>" . $text . "</strong>  <em>Posted " . date('n/j/y g:i a', $time) . "</em></p>";
    }
    return true;
    sleep(1);
}
getTweets('#repidee13');
<?php

chdir('../');
require_once 'includes/db.inc.php';
$imwidth = 1024;
$imheight = 768;
$font = 'includes/segoepr.ttf';
$spacing = 1.25;
$gaussian = array(array(1.0, 2.0, 1.0), array(2.0, 4.0, 2.0), array(1.0, 2.0, 1.0));
$image = imagecreatetruecolor($imwidth, $imheight);
$black = imagecolorallocate($image, 0, 0, 0);
$white = imagecolorallocate($image, 255, 255, 255);
$blackblur = imagecolorallocatealpha($image, 0, 0, 0, 115);
$blackblurfg = imagecolorallocatealpha($image, 0, 0, 0, 50);
imagefill($image, 0, 0, $black);
$statuses = array_reverse(getTweets(100));
$i = 0;
foreach ($statuses as $status) {
    $i += 1;
    $size = 10 + 14 / count($statuses);
    if (count($statuses) == $i) {
        $size += 6;
    } elseif (count($statuses) - 1 == $i) {
        $size += 4;
    } elseif (count($statuses) - 2 == $i) {
        $size += 2;
    }
    $angle = 0;
    $x = 0;
    $y = 0;
    $direct = '';
Exemple #25
0
// define('CONSUMER_KEY', '');
// define('CONSUMER_SECRET', '');
// define('ACCESS_TOKEN', '');
// define('ACCESS_TOKEN_SECRET', '');
// class forTwitterApi
// {
// static function getTweets($keyword)
function getTweets($keyword)
{
    // twitteroauthのインスタンス生成
    $twitterOAuth = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
    // APIに渡すパラメータを設定
    $param = array("q" => $keyword, "lang" => "ja", "count" => 10, "result_type" => "recent");
    // TwitterのAPIへ
    $json = $twitterOAuth->OAuthRequest("https://api.twitter.com/1.1/search/tweets.json", "GET", $param);
    // jsonデコードして返す
    return json_decode($json, true);
}
// }
// 表示はテンプレートに書きましょう
/* ↓↓↓ ここから表示 ↓↓↓ */
// $result = forTwitterApi::getTweets("#ハッシュタグ");
$result = getTweets("#ハッシュタグ");
// 全件表示
if ($result['statuses']) {
    foreach ($result['statuses'] as $tweet) {
        echo file_get_contents($tweet["user"]["profile_image_url"]);
    }
} else {
    echo "Not Found Tweets";
}
Exemple #26
0
    function widget($args, $instance)
    {
        extract($args);
        /* set the twitter widget status to true so we can load additional js scrips in functions.php */
        //global $twitter_widget_status;
        //$twitter_widget_status = true;
        $title = $instance['title'];
        $title = apply_filters('widget_title', empty($instance['title']) ? __('Latest tweets', 'framework') : $instance['title'], $instance, $this->id_base);
        $twitter_name = $instance['twitter_name'];
        if (!($number = (int) $instance['number'])) {
            $number = 3;
        } else {
            if ($number < 1) {
                $number = 1;
            } else {
                if ($number > 12) {
                    $number = 12;
                }
            }
        }
        ?>

			<?php 
        echo $before_widget;
        ?>
				<?php 
        echo $before_title . $title . $after_title;
        if (function_exists('getTweets')) {
            $tweets = getTweets($number, $twitter_name);
            ?>
				<div class="twitter-widget-wrapper">
                	
                    <img src="<?php 
            echo get_template_directory_uri();
            ?>
/images/twitter_logo.png" alt="<?php 
            esc_attr__('twitter', 'framework');
            ?>
" class="tw-img" />
                    
                    
                    <div class="all-tweets">
                    	<a href="http://twitter.com/<?php 
            echo $twitter_name;
            ?>
" class="tooltip-link" data-toggle="tooltip" data-placement="bottom" data-original-title="<?php 
            _e('View All Tweets', 'framework');
            ?>
">
                    		<i class="fa fa-twitter"></i>
                        </a>
                    </div>
                	
                    
                    <div class="flexslider-twitter">
                    
                    
                    <ul class="twitter-content slides">
    
                    <?php 
            if (is_array($tweets)) {
                foreach ($tweets as $tweet) {
                    ?>
                            <li>
                                <div class="gw-tweet">
                                <?php 
                    if ($tweet['text']) {
                        $the_tweet = $tweet['text'];
                        // i. User_mentions must link to the mentioned user's profile.
                        if (is_array($tweet['entities']['user_mentions'])) {
                            foreach ($tweet['entities']['user_mentions'] as $key => $user_mention) {
                                $the_tweet = preg_replace('/@' . $user_mention['screen_name'] . '/i', '<a href="http://www.twitter.com/' . $user_mention['screen_name'] . '" target="_blank">@' . $user_mention['screen_name'] . '</a>', $the_tweet);
                            }
                        }
                        // ii. Hashtags must link to a twitter.com search with the hashtag as the query.
                        if (is_array($tweet['entities']['hashtags'])) {
                            foreach ($tweet['entities']['hashtags'] as $key => $hashtag) {
                                $the_tweet = preg_replace('/#' . $hashtag['text'] . '/i', '<a href="https://twitter.com/search?q=%23' . $hashtag['text'] . '&src=hash" target="_blank">#' . $hashtag['text'] . '</a>', $the_tweet);
                            }
                        }
                        // iii. Links in Tweet text must be displayed using the display_url field in the URL entities API response, and link to the original t.co url field.
                        if (is_array($tweet['entities']['urls'])) {
                            foreach ($tweet['entities']['urls'] as $key => $link) {
                                $the_tweet = preg_replace('`' . $link['url'] . '`', '<a href="' . $link['url'] . '" target="_blank">' . $link['url'] . '</a>', $the_tweet);
                            }
                        }
                        echo $the_tweet;
                        // 3. Tweet Timestamp
                        //    The Tweet timestamp must always be visible and include the time and date. e.g., “3:00 PM - 31 May 12”.
                        // 4. Tweet Permalink
                        //    The Tweet timestamp must always be linked to the Tweet permalink.
                        echo '
                                <p class="tw-timestamp">
                                    <a href="https://twitter.com/' . esc_url($twitter_name) . '/status/' . $tweet['id_str'] . '" target="_blank">' . date('M d Y h:i A', strtotime($tweet['created_at'])) . '</a>
                                </p>';
                        // 5. Tweet Actions
                        echo '
                                <div class="twitter_intents">
                                    <p><a title="reply" href="https://twitter.com/intent/tweet?in_reply_to=' . $tweet['id_str'] . '"><i class="icon-reply"></i></a></p>
                                    <p><a title="retweet" href="https://twitter.com/intent/retweet?tweet_id=' . $tweet['id_str'] . '"><i class="icon-retweet"></i></a></p>
                                    <p><a title="favorite" href="https://twitter.com/intent/favorite?tweet_id=' . $tweet['id_str'] . '"><i class="icon-star"></i></a></p>
    
                                </div>';
                    } else {
                        ?>
                                <a href="http://twitter.com/<?php 
                        echo esc_url($twitter_name);
                        ?>
"><?php 
                        _e('Click here to read the twitter feed', 'framework');
                        ?>
</a>
                                <?php 
                    }
                    ?>
                            
                            </div><!-- end of .gw-tweet -->
                        </li><?php 
                }
                // end of foreach
            }
            // end of is_array
            ?>
                    
                    </ul>
                    
                    
                    </div>
                    
                    

                
                </div>

                
				<?php 
        } else {
            ?>
	                <ul class="twitter-content">
					<li><?php 
            _e('Please install the oAuth Twitter Feed for Developers plugin to have a working twitter widget.', 'framework');
            ?>
</li>
                    </ul>
				<?php 
        }
        ?>
                
                
			<?php 
        echo $after_widget;
        ?>

        <?php 
    }
Exemple #27
0
    curl_close($ch);
    //If you want to see the response from Twitter, uncomment this next part out:
    echo "<p>Response:</p>";
    echo "<pre>" . htmlspecialchars($xml) . "</pre>";
    $affected = 0;
    $twelement = new SimpleXMLElement($xml);
    foreach ($twelement->entry as $entry) {
        $text = trim($entry->title);
        $author = trim($entry->author->name);
        $time = strtotime($entry->published);
        $id = $entry->id;
        echo "<p>Tweet from " . $author . ": <strong>" . $text . "</strong>  <em>Posted " . date('n/j/y g:i a', $time) . "</em></p>";
    }
    return true;
}
getTweets('#cats');
//print_r($_SERVER);
$b = 0;
$a = "";
echo '$b==false ', $b == false, '<br>';
echo '$a==false ', $a == false, '<br>';
echo '$b!==false ', $b !== false, '<br>';
echo '$b==false ', $b == false, '<br>';
echo '$b===false ', $b === false, '<br>';
echo '$b!==true ', $b !== true, '<br>';
echo 00 * 1.5;
echo 12 ^ 9;
$x = 5;
echo $x >> 2;
$a = array(1, 2, 3, 4);
echo array_shift($a);
    /**
     * Outputs the content for the current Text widget instance.
     *
     * @since 2.8.0
     * @access public
     *
     * @param array $args     Display arguments including 'before_title', 'after_title',
     *                        'before_widget', and 'after_widget'.
     * @param array $instance Settings for the current Text widget instance.
     */
    public function widget($args, $instance)
    {
        add_action('wp_footer', array($this, 'baldwin_twitter_widget_init'), 99);
        $widget_title = !empty($instance['title']) ? $instance['title'] : '';
        $widget_text = !empty($instance['text']) ? $instance['text'] : '';
        $widget_twitter = !empty($instance['twitter']) ? $instance['twitter'] : '';
        /**
         * Filter the content of the Text widget.
         *
         * @since 2.3.0
         * @since 4.4.0 Added the `$this` parameter.
         *
         * @param string         $widget_text The widget content.
         * @param array          $instance    Array of settings for the current widget.
         * @param WP_Widget_Text $this        Current Text widget instance.
         */
        $text = apply_filters('widget_text', $widget_text, $instance, $this);
        echo $args['before_widget'];
        ?>
            <div class="l-half-section right bg-bg-gray"></div>
            <div class="row l-ignore-overlay">
                <div class="six columns push_one light typography l-padded-small">
                    <h2 class="no-pad"><?php 
        echo $widget_title;
        ?>
</h2>
                    <hr class="border-green" />
                    <?php 
        echo !empty($instance['filter']) ? wpautop($text) : $text;
        ?>
                </div>

                <div class="six columns push_two dark typography">
                    <h4 class="l-v-margin text-center"><i class="icon-twitter"></i></h4>
                    <?php 
        $tweets = getTweets($widget_twitter, 5);
        ?>
                    <div id="twitter-carousel" class="owl-carousel">
                    <?php 
        foreach ($tweets as $tweet) {
            ?>
                        <div>
                            <p class="l-v-margin large text-center"><?php 
            echo $tweet['text'];
            ?>
</p>
                            <p class="l-v-margin xlarge smaller italic text-center"><?php 
            echo $widget_twitter;
            ?>
 | <?php 
            echo rdmgumby_time_ago(strtotime($tweet['created_at']));
            ?>
</p>
                        </div>
                    <?php 
        }
        ?>
                    </div>
                </div>
            </div>

		<?php 
        echo $args['after_widget'];
    }
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', $instance['title']);
        $notweets = $instance['notweets'];
        echo $before_widget;
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        ?>
		
		<!-- Tweets List -->
		<?php 
        $tweets = getTweets($notweets);
        //change number up to 20 for number of tweets
        if (!isset($tweets['error'])) {
            if (is_array($tweets)) {
                // to use with intents
                echo '<script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>';
                echo '<ul class="twitter_update_list">';
                foreach ($tweets as $tweet) {
                    echo '<li>';
                    if ($tweet['text']) {
                        $the_tweet = $tweet['text'];
                        /*
                        Twitter Developer Display Requirements
                        https://dev.twitter.com/terms/display-requirements
                        
                        2.b. Tweet Entities within the Tweet text must be properly linked to their appropriate home on Twitter. For example:
                          i. User_mentions must link to the mentioned user's profile.
                         ii. Hashtags must link to a twitter.com search with the hashtag as the query.
                        iii. Links in Tweet text must be displayed using the display_url
                             field in the URL entities API response, and link to the original t.co url field.
                        */
                        // i. User_mentions must link to the mentioned user's profile.
                        if (is_array($tweet['entities']['user_mentions'])) {
                            foreach ($tweet['entities']['user_mentions'] as $key => $user_mention) {
                                $the_tweet = preg_replace('/@' . $user_mention['screen_name'] . '/i', '<a href="http://www.twitter.com/' . $user_mention['screen_name'] . '" target="_blank">@' . $user_mention['screen_name'] . '</a>', $the_tweet);
                            }
                        }
                        // ii. Hashtags must link to a twitter.com search with the hashtag as the query.
                        if (is_array($tweet['entities']['hashtags'])) {
                            foreach ($tweet['entities']['hashtags'] as $key => $hashtag) {
                                $the_tweet = preg_replace('/#' . $hashtag['text'] . '/i', '<a href="https://twitter.com/search?q=%23' . $hashtag['text'] . '&src=hash" target="_blank">#' . $hashtag['text'] . '</a>', $the_tweet);
                            }
                        }
                        // iii. Links in Tweet text must be displayed using the display_url
                        //      field in the URL entities API response, and link to the original t.co url field.
                        if (is_array($tweet['entities']['urls'])) {
                            foreach ($tweet['entities']['urls'] as $key => $link) {
                                $the_tweet = preg_replace('`' . $link['url'] . '`', '<a href="' . $link['url'] . '" target="_blank">' . $link['url'] . '</a>', $the_tweet);
                            }
                        }
                        echo '<div class="twitter-text">';
                        echo $the_tweet;
                        echo '</div>';
                        // 3. Tweet Actions
                        //    Reply, Retweet, and Favorite action icons must always be visible for the user to interact with the Tweet. These actions must be implemented using Web Intents or with the authenticated Twitter API.
                        //    No other social or 3rd party actions similar to Follow, Reply, Retweet and Favorite may be attached to a Tweet.
                        // get the sprite or images from twitter's developers resource and update your stylesheet
                        // echo '
                        // <div class="twitter_intents">
                        //     <a class="reply" href="https://twitter.com/intent/tweet?in_reply_to='.$tweet['id_str'].'">Reply</a>
                        //     <a class="retweet" href="https://twitter.com/intent/retweet?tweet_id='.$tweet['id_str'].'">Retweet</a>
                        //     <a class="favorite" href="https://twitter.com/intent/favorite?tweet_id='.$tweet['id_str'].'">Favorite</a>
                        // </div>';
                        // 4. Tweet Timestamp
                        //    The Tweet timestamp must always be visible and include the time and date. e.g., “3:00 PM - 31 May 12”.
                        // 5. Tweet Permalink
                        //    The Tweet timestamp must always be linked to the Tweet permalink.
                        echo '
					      <a class="timesince" href="https://twitter.com/' . $tweet['user']['screen_name'] . '/status/' . $tweet['id_str'] . '" target="_blank">
					          ' . twitter_time(date('h:i A M d', strtotime($tweet['created_at'] . '- 8 hours'))) . '
					      </a>';
                        // -8 GMT for Pacific Standard Time
                    } else {
                        echo '
						  <br />
						  <a href="http://twitter.com/' . $tweet['user']['screen_name'] . '" target="_blank">Click here to read ' . $tweet['user']['screen_name'] . '\'s Twitter feed</a>';
                    }
                    echo '</li>';
                }
                echo '</ul>';
            }
        }
        ?>
		<!-- //Tweets List -->
		
		<?php 
        echo $after_widget;
    }
<?php

require_once '../../../../wp-config.php';
$theme_opts = get_option('marisa_options');
require_once "twitteroauth.php";
//Path to twitteroauth library
function getTweets($twitteruser)
{
    $notweets = 6;
    $consumerkey = "91VWoS0052BKjczqL9LMNKumm";
    $consumersecret = "YPrff3DTDtUw0i3iSRlGQGaGEEG2kW6CqwBFA5PV0Hfs62NDY7";
    $accesstoken = "27766009-jWBg4UotrwxP4f3WWYuwHFlwZeg6fJrrKmXOu52CF";
    $accesstokensecret = "1bAeS1A2wBzkqkPbQZOxViqDb2sOPblPe9IugMz9YsMnI";
    function getConnectionWithAccessToken($cons_key, $cons_secret, $oauth_token, $oauth_token_secret)
    {
        $connection = new TwitterOAuth($cons_key, $cons_secret, $oauth_token, $oauth_token_secret);
        return $connection;
    }
    $connection = getConnectionWithAccessToken($consumerkey, $consumersecret, $accesstoken, $accesstokensecret);
    $tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=" . $twitteruser . "&count=" . $notweets);
    return $tweets;
}
$tweets = getTweets($theme_opts['marisa_twitter']);
foreach ($tweets as $line) {
    $status = $line->text;
    $tweetTime = $line->created_at;
    $tweetId = $line->id_str;
    $tweetImg = $line->user->profile_image_url;
    $outputTweet = '<li><img src="' . $tweetImg . '"/>' . $status . '</span> <a style="font-size:85%" href="http://twitter.com/' . $twitteruser . '/statuses/' . $tweetId . '">' . $tweetTime . '</a></li>';
    echo $outputTweet;
}