本文整理汇总了PHP中getConnectionWithAccessToken函数的典型用法代码示例。如果您正苦于以下问题:PHP getConnectionWithAccessToken函数的具体用法?PHP getConnectionWithAccessToken怎么用?PHP getConnectionWithAccessToken使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getConnectionWithAccessToken函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($arr)
{
$this->services = $arr;
if (trim($arr['twitterName'])) {
$connection = getConnectionWithAccessToken($arr['consumer_key'], $arr['consumer_secret'], $arr['access_token'], $arr['access_token_secret']);
$tweets = $connection->get('https://api.twitter.com/1.1/users/show.json?screen_name=' . $arr['twitterName']) or die('Couldn\'t retrieve tweets! Wrong username?');
if (!empty($tweets->errors)) {
if ($tweets->errors[0]->message == 'Invalid or expired token') {
echo '<strong>' . $tweets->errors[0]->message . '!</strong><br />You\'ll need to regenerate it <a href="https://dev.twitter.com/apps" target="_blank">here</a>!' . $after_widget;
} else {
echo '<strong>' . $tweets->errors[0]->message . '</strong>' . $after_widget;
}
return;
}
$new_twitter = $tweets->followers_count;
if (empty($new_twitter) || $new_twitter == 0 || $new_twitter == '0') {
$this->twitter = $arr['twitter'];
} else {
$this->twitter = $new_twitter;
}
}
if (trim($arr['facebookFanPageURL'])) {
$query = wp_remote_get('https://api.facebook.com/method/links.getStats?urls=' . urlencode(trim($arr['facebookFanPageURL'])) . '&format=json');
if (is_wp_error($query)) {
print_r($query);
}
$result = json_decode($query['body'], true);
if (empty($result[0]['like_count']) || $result[0]['like_count'] == 0 || $result[0]['like_count'] == '0') {
$this->facebook = $arr['facebook'];
} else {
$this->facebook = $result[0]['like_count'];
}
}
}
示例2: etheme_capture_tweets
function etheme_capture_tweets($consumer_key, $consumer_secret, $user_token, $user_secret, $user, $count)
{
$connection = getConnectionWithAccessToken($consumer_key, $consumer_secret, $user_token, $user_secret);
$params = array('screen_name' => $user, 'count' => $count);
$content = $connection->get("statuses/user_timeline", $params);
//prar($content);
return json_encode($content);
}
示例3: widget
function widget($args, $instance)
{
extract($args);
$title = apply_filters('widget_title', $instance['title']);
$twitter_username = $instance['twitter_username'];
$show_num = $instance['show_num'];
$consumer_key = $instance['consumer_key'];
$consumer_secret = $instance['consumer_secret'];
$access_token = $instance['access_token'];
$access_token_secret = $instance['access_token_secret'];
$cache_time = $instance['cache_time'];
// Opening of widget
echo $before_widget;
// Open of title tag
if ($title) {
echo $before_title . $title . $after_title;
}
$last_cache_time = get_option('gdl_twitter_widget_last_cache_time', 0);
$diff = time() - $last_cache_time;
$crt = $cache_time * 3600;
if (empty($last_cache_time) || $diff >= $crt) {
$connection = getConnectionWithAccessToken($consumer_key, $consumer_secret, $access_token, $access_token_secret);
$tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=" . $twitter_username . "&count=" . $show_num) or die('Couldn\'t retrieve tweets! Wrong username?');
if (!empty($tweets->errors)) {
if ($tweets->errors[0]->message == 'Invalid or expired token') {
echo '<strong>' . $tweets->errors[0]->message . '!</strong><br />You\'ll need to regenerate it <a href="https://dev.twitter.com/apps" target="_blank">here</a>!' . $after_widget;
} else {
echo '<strong>' . $tweets->errors[0]->message . '</strong>' . $after_widget;
}
return;
}
$tweets_data = array();
for ($i = 0; $i <= count($tweets); $i++) {
if (!empty($tweets[$i])) {
$tweets_data[$i]['created_at'] = $tweets[$i]->created_at;
$tweets_data[$i]['text'] = $tweets[$i]->text;
$tweets_data[$i]['status_id'] = $tweets[$i]->id_str;
}
}
update_option('gdl_twitter_widget_tweets', serialize($tweets_data));
update_option('gdl_twitter_widget_last_cache_time', time());
} else {
$tweets_data = maybe_unserialize(get_option('gdl_twitter_widget_tweets'));
}
echo '<div class="twitter-whole">';
echo '<ul id="twitter_update_list">';
foreach ($tweets_data as $each_tweet) {
echo '<li>';
echo '<span>' . convert_links($each_tweet['text']) . '</span>';
echo '<a target="_blank" href="http://twitter.com/' . $twitter_username . '/statuses/' . $each_tweet['status_id'] . '">' . relative_time($each_tweet['created_at']) . '</a>';
echo '</li>';
}
echo '</ul>';
echo '</div>';
// Closing of widget
echo $after_widget;
}
示例4: tweet
function tweet($update)
{
global $config;
$connection = getConnectionWithAccessToken($config['twitter_oauth_token'], $config['twitter_oauth_token_secret']);
$parameters = array('status' => $update);
$status = $connection->post('statuses/update', $parameters);
// Don't uncomment this as it will break "Update" button in OpenURL results
//print_r($status);
}
示例5: get
function get($count = 20)
{
$username = $this->username;
// Append the count
$url = $this->feedUrl;
$url .= '&count=' . $count;
$tweets_cache_path = get_template_directory() . '/cache/twitter_' . $username . '_' . $count . '.cache';
if (file_exists($tweets_cache_path)) {
$tweets_cache_timer = intval((time() - filemtime($tweets_cache_path)) / 60);
} else {
$tweets_cache_timer = 0;
}
if (!file_exists($tweets_cache_path) or $tweets_cache_timer > 15) {
$connection = getConnectionWithAccessToken($this->consumer_key, $this->consumer_secret, $this->access_token, $this->access_token_secret);
$tweets = $connection->get($url);
if (!empty($tweets->errors)) {
if ($tweets->errors[0]->message == 'Invalid or expired token') {
echo '<strong>' . $tweets->errors[0]->message . '!</strong><br />You\'ll need to regenerate it <a href="https://dev.twitter.com/apps" target="_blank">here</a>!' . $after_widget;
} else {
echo '<strong>' . $tweets->errors[0]->message . '</strong>' . $after_widget;
}
return;
}
$tweets_data = array();
foreach ($tweets as $tweet) {
$tweets_data[]['text'] = $tweet->text;
}
if (file_exists($tweets_cache_path)) {
unlink($tweets_cache_path);
}
$myFile = $tweets_cache_path;
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = serialize($tweets_data);
fwrite($fh, $stringData);
fclose($fh);
//clear data
$tweets_data = array();
}
error_reporting(0);
$file = file_get_contents($tweets_cache_path, true);
if (!empty($file)) {
$tweets = unserialize($file);
// Some reformatting
$pattern = array('/[^(:\\/\\/)](www\\.[^ \\n\\r]+)/', '/(https?:\\/\\/[^ \\n\\r]+)/');
$replace = array('<a href="http://$1" rel="nofollow">$1</a>', '<a href="$1" rel="nofollow">$1</a>');
foreach ($tweets as $tweet) {
$formatted_tweet = preg_replace($pattern, $replace, $tweet['text']);
$formatted_tweet = auto_link_twitter($formatted_tweet);
$tweets_data[]['text'] = $formatted_tweet;
}
}
return $tweets_data;
}
示例6: __construct
public function __construct($lng, $lat)
{
require_once $_SERVER['DOCUMENT_ROOT'] . "/twitteroauth-master/connect.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/twitteroauth-master/twitteroauth/twitteroauth.php";
function getConnectionWithAccessToken($oauth_token, $oauth_token_secret)
{
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $oauth_token, $oauth_token_secret);
return $connection;
}
$connection = getConnectionWithAccessToken("53207076-VqragtGcaPWoldCNrfbnwwWG4dUnP0BbeKcW4xt8m", "OdeBMzodirvxoDrgkKJxNvkEBeB87TUCkamvMpqyULsgq");
$content = $connection->get("https://api.twitter.com/1.1/geo/search.json?accuracy=3000&lat=38.6480&long=-90.3050");
$place_id = $content->result->places[0]->id;
$base_url = "https://twitter.com/search?q=place%3A" . $place_id;
echo $base_url;
}
示例7: getTweets
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;
}
示例8: get
function get($count = 20)
{
$username = $this->username;
// Append the count
$url = $this->feedUrl;
$url .= '&count=' . $count;
$tweets_cache_path = THEMEUPLOAD . '/twitter_' . $username . '_' . $count . '.cache';
if (file_exists($tweets_cache_path)) {
$tweets_cache_timer = intval((time() - filemtime($tweets_cache_path)) / 60);
} else {
$tweets_cache_timer = 0;
}
if (!file_exists($tweets_cache_path) or $tweets_cache_timer > 15) {
$connection = getConnectionWithAccessToken($this->consumer_key, $this->consumer_secret, $this->access_token, $this->access_token_secret);
$tweets = $connection->get($url);
if (!empty($tweets->errors)) {
if ($tweets->errors[0]->message == 'Invalid or expired token') {
echo '<strong>' . $tweets->errors[0]->message . '!</strong><br />You\'ll need to regenerate it <a href="https://dev.twitter.com/apps" target="_blank">here</a>!';
} else {
echo '<strong>' . $tweets->errors[0]->message . '</strong>';
}
return;
}
$tweets_data = array();
foreach ($tweets as $tweet) {
$tweet_text = auto_link_twitter($tweet->text);
$tweets_data[]['text'] = $tweet_text;
}
if (file_exists($tweets_cache_path)) {
unlink($tweets_cache_path);
}
$myFile = $tweets_cache_path;
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = serialize($tweets_data);
fwrite($fh, $stringData);
fclose($fh);
} else {
$file = file_get_contents($tweets_cache_path, true);
if (!empty($file)) {
$tweets = unserialize($file);
foreach ($tweets as $tweet) {
$tweets_data[]['text'] = $tweet['text'];
}
}
}
return $tweets_data;
}
示例9: twitter_parse_cache_feed
function twitter_parse_cache_feed($args = '')
{
/* Set up the default arguments for the twitter. */
$defaults = array('username' => '', 'limit' => '', 'encode_utf8' => 'false', 'twitter_cons_key' => '', 'twitter_cons_secret' => '', 'twitter_oauth_token' => '', 'twitter_oauth_secret' => '');
$args = apply_filters('twitter_parse_cache_feed_args', $args);
$args = wp_parse_args($args, $defaults);
$out = '';
global $twitter_options;
if (!(require_once FRAMEWORK_DIR . 'includes/twitteroauth.php')) {
$out .= '<strong>Couldn\'t find twitteroauth.php!</strong>';
return;
}
$connection = getConnectionWithAccessToken($args['twitter_cons_key'], $args['twitter_cons_secret'], $args['twitter_oauth_token'], $args['twitter_oauth_secret']);
$tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=" . $args['username'] . "&count=" . $args['limit'] . "") or die('Couldn\'t retrieve tweets! Wrong username?');
//print_r($tweets);
if (!empty($tweets->errors)) {
if ($tweets->errors[0]->message == 'Invalid or expired token') {
$out .= '<strong>' . $tweets->errors[0]->message . '!</strong><br />You\'ll need to regenerate it <a href="https://dev.twitter.com/apps" target="_blank">here</a>!' . $after_widget;
} else {
$out .= '<strong>' . $tweets->errors[0]->message . '</strong>';
}
return;
}
$out .= '<ul class="tweet">';
for ($i = 0; $i <= count($tweets); $i++) {
if (!empty($tweets[$i])) {
$out .= '<li><i class="icon-twitter"></i>';
$msg = " " . $tweets[$i]->text . " ";
if ($args['encode_utf8']) {
$msg = utf8_encode($msg);
}
//$link = $message->get_link();
$time = $tweets[$i]->created_at;
$msg = hyperlinks($msg);
$msg = twitter_users($msg);
$out .= $msg;
$out .= '<span> - ' . relativeTime($time) . '</span>';
$out .= '</li>';
}
}
$out .= '</ul>';
echo $out;
}
示例10: get_recent_tweet_by_username
function get_recent_tweet_by_username($username = null)
{
if ($username) {
$twitteruser = $username;
$number = 1;
$consumerkey = get_field('sdo_api_twitter_app_consumer_key', 'options');
$consumersecret = get_field('sdo_api_twitter_app_consumer_secret', 'options');
$accesstoken = get_field('sdo_api_twitter_app_access_token', 'options');
$accesstokensecret = get_field('sdo_api_twitter_app_access_token_secret', 'options');
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);
$tweet = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=" . $twitteruser . "&count=" . $number . "&exclude_replies=true&include_rts=false&contributor_details=true&include_entities=true");
return $tweet[0];
}
}
示例11: get_tweets
function get_tweets()
{
// The $_REQUEST contains all the data sent via ajax
if (isset($_REQUEST)) {
/*// get Vancouver weather from Environment Canada
$xml=simplexml_load_file("https://weather.gc.ca/rss/city/bc-74_e.xml") or $xml = null;
$weather = "";
if ($xml) {
$weather = $xml->entry[1]->title;
$weather = substr($weather, 20); // removes "Current Conditions: " from beginning.
$date = $xml->entry[1]->updated;
$date = new DateTime($date);
$date = $date->format('d/m/y');
$weather = $date." | ".$weather;
}
echo ($weather);*/
require_once "twitteroauth-master/twitteroauth/twitteroauth.php";
//Path to twitteroauth library
$twitteruser = "fieldhockeycan";
$notweets = 2;
$consumerkey = "PlxuNdfmNQg1rt9pnF0L8K1kU";
$consumersecret = "Wkulo79SOsEmlQvqmSCDaiDbO8ywRa0JIvvoBMFdaYPL2d5gH6";
$accesstoken = "14864996-Ya9fNZarCjMYNyK6HPluj0Mothx3LpioeOdJYCEM5";
$accesstokensecret = "lqGV9eWg3X6mEWDSnuz4no83cGMXtIZYV6QSNd2jprC0f";
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);
echo json_encode($tweets);
}
// Always die in functions echoing ajax content
die;
}
示例12: twitter_get_tweets
function twitter_get_tweets($twitteruser)
{
$cache = get_transient('revoke_twitter');
if (is_array($cache) && array_key_exists($twitteruser, $cache)) {
return $cache[$twitteruser];
}
$consumerkey = _go('twitter_consumerkey');
$consumersecret = _go('twitter_consumersecret');
$accesstoken = _go('twitter_accesstoken');
$accesstokensecret = _go('twitter_accesstokensecret');
if (empty($consumerkey) || empty($consumersecret) || empty($accesstoken) || empty($accesstokensecret)) {
return null;
}
$connection = getConnectionWithAccessToken($consumerkey, $consumersecret, $accesstoken, $accesstokensecret);
$tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=" . $twitteruser);
if (!is_array($cache)) {
$cache = array();
}
$cache[$twitteruser] = $tweets;
set_transient('revoke_twitter', $cache, 60);
return $tweets;
}
示例13: chronos_twitter_feed
function chronos_twitter_feed($count = '1', $list = false)
{
global $user, $consumerkey, $consumersecret, $accesstoken, $accesstokensecret;
$output = '';
$i = 1;
$twitteruser = $user;
$notweets = $count;
$connection = getConnectionWithAccessToken($consumerkey, $consumersecret, $accesstoken, $accesstokensecret);
$tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=" . $twitteruser . "&count=" . $notweets);
$data = json_decode(json_encode($tweets));
if (is_array($data)) {
while ($i <= $count) {
if (isset($data[$i - 1])) {
$feed = $data[$i - 1]->text;
$feed = str_pad($feed, 3, ' ', STR_PAD_LEFT);
$startat = stripos($feed, '@');
$numat = substr_count($feed, '@');
$numhash = substr_count($feed, '#');
$numhttp = substr_count($feed, 'http');
$feed = preg_replace("#(^|[\n ])([\\w]+?://[\\w]+[^ \"\n\r\t< ]*)#", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $feed);
$feed = preg_replace("#(^|[\n ])((www|ftp)\\.[^ \"\t\n\r< ]*)#", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $feed);
$feed = preg_replace("/@(\\w+)/", "<a href=\"http://www.twitter.com/\\1\" target=\"_blank\">@\\1</a>", $feed);
$feed = preg_replace("/#(\\w+)/", "<a href=\"http://search.twitter.com/search?q=\\1\" target=\"_blank\">#\\1</a>", $feed);
if (!$list) {
$output .= sprintf('<div class="">%2$s</div><div class="">%1$s</div>', $feed, chronos_time_ago(strtotime($data[$i - 1]->created_at)));
} else {
$output .= sprintf('<div class="single_row margin-bottom24"><i class="fa fa-twitter icon_element"></i><div class="text border-box">%1$s</div><div class="clearfix"></div></div><!-- single_row -->', $feed);
}
if ($i !== $count && $list) {
$output .= '<div class="small_separator background-color-passive margin-bottom24"></div>';
}
}
$i++;
}
return $output;
} else {
return 'Twitter unaviable';
}
}
示例14: get_theme_tweets
function get_theme_tweets($username, $consumerkey, $consumerkeysecret, $accesstoken, $accesstokensecret, $notweets)
{
//check settings and die if not set
if (empty($username) || empty($consumerkey) || empty($consumerkeysecret) || empty($accesstoken) || empty($accesstokensecret)) {
echo '<strong>Please fill all Twitter settings!</strong>';
return;
}
// yes, it needs update
if (!(require_once 'twitter_oauth.php')) {
echo '<strong>Couldn\'t find twitter_oauth.php!</strong>';
return;
}
if (!function_exists('getConnectionWithAccessToken')) {
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, $consumerkeysecret, $accesstoken, $accesstokensecret);
$tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=" . $username . "&count=5") or die('Couldn\'t retrieve tweets! Wrong username?');
if (!empty($tweets->errors)) {
if ($tweets->errors[0]->message == 'Invalid or expired token') {
echo '<strong>' . $tweets->errors[0]->message . '!</strong><br />You will need to regenerate it <a href="https://dev.twitter.com/apps" target="_blank">here</a>!' . $after_widget;
} else {
echo '<strong>' . $tweets->errors[0]->message . '</strong>' . $after_widget;
}
return;
}
for ($i = 0; $i <= count($tweets); $i++) {
if (!empty($tweets[$i])) {
$tweets_array[$i]['created_at'] = $tweets[$i]->created_at;
$tweets_array[$i]['text'] = $tweets[$i]->text;
$tweets_array[$i]['status_id'] = $tweets[$i]->id_str;
}
}
set_transient('twitter-bar-tweets', $tweets_array, 0);
//convert links to clickable format
function convert_links($status, $targetBlank = true, $linkMaxLen = 250)
{
// the target
$target = $targetBlank ? " target=\"_blank\" " : "";
// convert link to url
$status = preg_replace("/((http:\\/\\/|https:\\/\\/)[^ )\n]+)/e", "'<a href=\"\$1\" title=\"\$1\" {$target} >'. ((strlen('\$1')>={$linkMaxLen} ? substr('\$1',0,{$linkMaxLen}).'...':'\$1')).'</a>'", $status);
// convert @ to follow
$status = preg_replace("/(@([_a-z0-9\\-]+))/i", "<a href=\"http://twitter.com/\$2\" title=\"Follow \$2\" {$target} >\$1</a>", $status);
// convert # to search
$status = preg_replace("/(#([_a-z0-9\\-]+))/i", "<a href=\"https://twitter.com/search?q=\$2\" title=\"Search \$1\" {$target} >\$1</a>", $status);
// return the status
return $status;
}
//convert dates to readable format
function relative_time($a)
{
//get current timestampt
$b = strtotime("now");
//get timestamp when tweet created
$c = strtotime($a);
//get difference
$d = $b - $c;
//calculate different time values
$minute = 60;
$hour = $minute * 60;
$day = $hour * 24;
$week = $day * 7;
if (is_numeric($d) && $d > 0) {
//if less then 3 seconds
if ($d < 3) {
return "right now";
}
//if less then minute
if ($d < $minute) {
return floor($d) . " seconds ago";
}
//if less then 2 minutes
if ($d < $minute * 2) {
return "about 1 minute ago";
}
//if less then hour
if ($d < $hour) {
return floor($d / $minute) . " minutes ago";
}
//if less then 2 hours
if ($d < $hour * 2) {
return "about 1 hour ago";
}
//if less then day
if ($d < $day) {
return floor($d / $hour) . " hours ago";
}
//if more then day, but less then 2 days
if ($d > $day && $d < $day * 2) {
return "yesterday";
}
//if less then year
if ($d < $day * 365) {
return floor($d / $day) . " days ago";
}
//else return more than a year
return "over a year ago";
//.........这里部分代码省略.........
示例15: getConnectionWithAccessToken
</p>
</div>
<br class="visiblephone">
<div class="span9">
<div class="well" style=" box-shadow:none !important; margin-bottom:0px; background:#303030; border:0px; border-radius:0px !important">
<?php
if (!(require_once 'inc/twitteroauth.php')) {
echo '<strong>Couldn\'t find twitteroauth.php!</strong>';
return;
}
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($b_data['TW_CONSUMER_KEY'], $b_data['TW_CONSUMER_SECRET'], $b_data['TW_OAUTH_TOKEN'], $b_data['TW_OAUTH_SECRET']);
$tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=" . $b_data['TW_USERNAME'] . "&count=" . $b_data['TW_NUMBER']);
if (!empty($tweets->errors)) {
if ($tweets->errors[0]->message == 'Invalid or expired token') {
echo '<strong>' . $tweets->errors[0]->message . '!</strong><br />You\'ll need to regenerate it <a href="https://dev.twitter.com/apps" target="_blank">here</a>!';
} else {
echo '<strong>' . $tweets->errors[0]->message . '</strong>';
}
}
if (is_array($tweets)) {
for ($i = 0; $i <= count($tweets); $i++) {
if (!empty($tweets[$i])) {
$tweets_array[$i]['created_at'] = $tweets[$i]->created_at;
$tweets_array[$i]['text'] = $tweets[$i]->text;
$tweets_array[$i]['status_id'] = $tweets[$i]->id_str;
}