Welcome, Guest. Please login or register.
Did you miss your activation email?
May 27, 2012, 12:49:52 AM

Login with username, password and session length
Search:     Advanced search
Interested in joining the WebsiteBaker team?
For more Information read here or on our new website.
155557 Posts in 21715 Topics by 7737 Members
Latest Member: gx-world
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: [SOLVED] Multiple Twitter account tweets in 1 block?  (Read 230 times)
Boudi
Addon Team

Offline Offline

Posts: 816



WWW
« on: January 24, 2012, 10:46:44 AM »

Hi,

Question: Is it possible to set a block in which you can read tweets created from different accounts?

I know there are some Twitter mods in which you can set an account and reads the tweets.

But my question is if you can set multiple accounts and read the tweets from all those accounts in one block.

Regards,

Boudi
« Last Edit: February 01, 2012, 03:10:21 PM by Boudi » Logged

...:: Bake the Unbakable ::...
Ruud
WebsiteBaker Org e.V.

Offline Offline

Posts: 2298



WWW
« Reply #1 on: January 30, 2012, 04:09:08 PM »

Here you go.
Based on the first twitter droplet I made some time ago:

Call it something like: multitweet
Usage: [[mulitweet?name=name1|name2|name3]]
Optional parameter &max={number-tweets-per-name}


Code: (droplet-code)
<?php 
//use [[multitweet?name=name1|name2|name3&max=5]]

if (isset($_SESSION['tweets'])) return $_SESSION['tweets']; //prevent too many calls
if (!isset($name)) return true;
if (!isset(
$max)) $max 10;
$nlist explode("|",$name);
$mytweets = array();
global 
$mytweets;

if (!
function_exists('fetch_tweets')) {
function fetch_tweets($username$maxtweets) {
global $mytweets;
$tweets simplexml_load_file("http://twitter.com/statuses/user_timeline/" $username ".rss");
foreach ( $tweets->channel->item as $tweet ) { 
if ($maxtweets == 0) {
break;
} else {
$twit $tweet->description;
$twit substr(strstr($twit': '), 2strlen($twit));
$twit preg_replace("/([\w]+:\/\/[\w-?&;#~=\.\/\@]+[\w\/])/i","<a target=\"_blank\" href=\"$1\">$1</a>",$twit);
$twit preg_replace("(@([a-zA-Z0-9\_]+))""<a target=\"_blank\" href=\"http://www.twitter.com/\\1\">\\0</a>"$twit);
$twit preg_replace('/(^|\s)#(\w+)/''\1<a target=\"_blank\" href="http://search.twitter.com/search?q=%23\2">#\2</a>'$twit);
$twit iconv("UTF-8"DEFAULT_CHARSET$twit);
$pubdate strtotime($tweet->pubDate); 
$propertime date(DATE_FORMAT.', '.TIME_FORMAT$pubdate);  //Customize this to your liking
$tweet_item = array('desc' => $twit,'date' => $propertime,'name'=>$username );
$mytweets[$pubdate] = $tweet_item;
$maxtweets--;
}
}
return;
}
}
foreach (
$nlist as $name) {
fetch_tweets($name$max);
}
krsort($mytweets);
$rval '<div class="twitter-updates">';
foreach (
$mytweets as $k => $v) {
     
$rval .= '<div><p class="twitter-name"><a href="https://twitter.com/#!/'.$v['name'].'" target="_blank">'.$v['name'].'</a></p><p class="twitter-update">' .$v['desc']. '</p><p class="twitter-date">' .$v['date']. '</p></div>';
}
$rval .= '</div>';
$_SESSION['tweets'] = $rval;
return 
$rval;
?>

« Last Edit: February 01, 2012, 03:09:54 PM by Ruud » Logged

Professional WebsiteBaker Solutions
Boudi
Addon Team

Offline Offline

Posts: 816



WWW
« Reply #2 on: February 01, 2012, 02:22:47 PM »

Thnx man!

Will check it out. And I know it works cauz you created it  grin

Boudi
Logged

...:: Bake the Unbakable ::...
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!