code /


script to show twitter tweets and twitpics together in zenphoto (or any other page)


note 18/11/2009

My code has been beautified and turned into a real zenphoto plugin byMicheall Malone


On my site I used MediaBoxAdvanced to show the external image links... this is not embedded in the code below.. You have to link back to twitter or twitpic in your page and using mediaboz/lightbox is a way around to prevent going to the twitter page by clicking the links without omitting the links .

please bare my bad scripting.. but it works :-)



// download SimplePie and extract the file
// and make a folder containing a php folder and a cache folder eg. simplepie/php and simplepie/php
// put the file from the download in the php folder
// put a 40x40 px profile thumb in the simplepie folder,jpg/png
// in this script change these values
// TWITTERUSERNAME your user name with a trailing: eg TWITTERUSERNAME: or JohnSmith:
// put this script in the simplefie folder call it zentwitter :-)
// create a page in zenphoto
// and put a include in your zenpage codeblock (make sure it gets printed..) like:
//<?php include ('LOCATION_OF_THIS_SCRIPT/simplepie/zentwitter.php');?>

$feed = new SimplePie();

//something like

// there is a bug in twitter rss header update regarding dates so disable cache


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "">
 <html xmlns="" xml:lang="en">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />

foreach ($feed->get_items() as $item):
$check = $item->get_description();
$check= strpos($check,"");
if($check === false){
$twit = $item->get_description();
$twit = explode('TWITTERUSERNAME:', $twit);?>

<div class="item" style="height:55px;margin-top:0px">
    <div style="margin-top:0px">
    <a><img align='top' HEIGHT='40' WIDTH='40' src='NAME_OF_A_40_X_40_PROFILE_THUMB'></a>
    <div style="margin-left:60px;margin-top:-45px"><small><?php echo $item->get_date('j/m/Y  G:i'); ?></small>   : <a href="<?php echo $item->get_link(); ?>"<?php echo $twit[1] ?></a>

<?php }else{

$data = $item->get_description();
$splitdata = explode('-', $data);
$pictwit = $splitdata[1];
$splitdata2 = explode('TWITTERUSERNAME:', $splitdata[0]);
$imgurl = explode('com', $splitdata2[1]);?>

<div class="item" style="height:55px;margin-top:0px">

    <div style="margin-top:0px">
    <?php echo "<a  title='$pictwit' href='$imgurl[1]'><img align='top' HEIGHT='40' WIDTH='40' src='$imgurl[1]'></a>";?>
    <div style="margin-left:60px;margin-top:-45px"><small><?php echo $item->get_date('j/m/Y  G:i'); ?>   :</small><?php echo $pictwit; ?>

<?php } ?>
<?php endforeach; ?>