本文整理汇总了PHP中getTweets函数的典型用法代码示例。如果您正苦于以下问题:PHP getTweets函数的具体用法?PHP getTweets怎么用?PHP getTweets使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getTweets函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: widget
/**
* 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'];
}
示例2: content
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> ' . $the_tweet . '</div>';
}
echo "</div>";
}
?>
<?php
$output = ob_get_contents();
ob_end_clean();
return $output;
}
示例3: widget
/**
* 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())));
}
示例4: widget
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 . '">→ Follow @' . $username . '</a></span></div>';
echo $after_widget;
}
示例5: search
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);
}
示例6: widget
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'] . '&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;
}
示例7: add_to_context
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;
}
示例8: getTweets
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]);
}
}
示例9: handleShortcode
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;
}
示例10: getTweets
$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">
示例11: die
<?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) {
示例12: getTweets
<?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']);
示例13: getTweets
<?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
}
示例14: extract
<?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;
示例15: brad_get_tweets
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'] . '&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';
}
}