twitter tips

How to import and display your latest tweets
Published on July 29th, 2011

If you are an active Twitter user, chances are that you want to share your latest tweets on your website or blog. To do that it’s quite easy, just use the following PHP snippet. <?php // import & display latest tweet $username = “perishable”; $feed = “”.$username.”&rpp=2″; // $prefix = ‘<h3>Perishable Press</h3>’; // $suffix = ‘<p><a href=”’.$username.’”>Follow me on Twitter</a>’; function parse_feed( $feed ) { $stepOne = explode( ‘<content type=”html”>’, $feed ); $stepTwo = explode( ‘</content>’, $stepOne[1] ); $tweet = $stepTwo[0]; $tweet = str_replace( “&lt;”, “<”, $tweet ); $tweet = str_replace( “&gt;”, “>”, $tweet ); return $tweet; } $latest_tweet = file_get_contents( $feed ); // echo stripslashes( $prefix ) . parse_feed( $latest_tweet ) . stripslashes( $suffix ); echo parse_feed( $latest_tweet ); ?>

How to add the official tweet button in WordPress
Published on May 22nd, 2011

Adding a “Tweet me” button with a counter in WordPress is quite easy with the button generator offered by Twitter itself. Then you can use this code.