December 23rd, 2009 | Categories: twitter

Here is a quick example how to display your Twitter feed just using Javascript and jQuery. As you know, this content won’t be available for spidering so it’s more for your users rather than SEO. Ok, lets get started.
If you haven’t already, let’s include jQuery into your site. Add the following script tag into the <head> of your site:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

Next we’re going to load the data from Twitter asynchronously. The following will do that:

<script type="text/javascript">
//Your twitter name
var twitter_name = "mikeluby";
//Number of tweets you want to get back
var twitter_count = 6;
//Callback function name
var callback_name = "tweet_callback";
//Twitter search url
var twitter_search = "http://twitter.com/statuses/user_timeline";
//Return type (json or xml)
var return_type = "json";
//Adds script tags to the head/body tag
( function() {
var ts = document.createElement('script');
ts.type = 'text/javascript';
ts.async = true;
ts.src = twitter_search + "." + return_type + "?screen_name=" + twitter_name + "&count=" + twitter_count + "&callback=" + callback_name;
( document.getElementsByTagName( 'head' )[ 0 ] || document.getElementsByTagName( 'body' )[ 0 ] ).appendChild( ts );
} )();
</script>

Ok you got the data now what? Let’s parse it and display it!

<script type="text/javascript">
//Call back function
function tweet_callback( data ) {
//Loop through the data from twitter
$.each( data, function( i, tweet ) {
//Make sure the text isn't undefined
if( tweet.text != undefined ) {
//Lets do some regex magic to replace urls, hashtags, and usernames
var text = tweet.text.toString().replace( /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig, '<a href="$1">$1</a>' ).replace( /(^|\s)@(\w+)/, '<a href="http://www.twitter.com/$2">@$2</a>' ).replace( /[#]+[A-Za-z0-9-_]+/ig, function(t) { var tag = t.replace("#","%23"); return t.link("http://search.twitter.com/search?q="+tag); } );
//Lets append each tweet to a ul with the id of tweet_container
$( "#tweet_container" ).append( "<li>" + text + "</li>");
}
} );
}</script>

There you go! The only limitation is if a user decides to visit the page (and make the twitter api calls) more than 100 times per hour.

For those who don’t know how to do a ul tag with an id:

<ul id="tweet_container"></ul>

Enjoy!

June 7th, 2009 | Categories: PHP

If you’re unfamiliar with Gnip (http://gnip.com/) pronounced “Guh-nip” it’s a content distribution solution for multiple publishers such as twitter, digg, flickr, tumblr, and many more. Rather than polling the service, Gnip allows you to set up a “push” type system where you let a callback URL and when there are new activities or notifications gnip will notify you through the URL provided. What I plan to show you here is a quick bit of code that allows you to quickly retrieve activities from filters using the Gnip PHP Convenience Library. I’m not going to go into a huge amount of depth and I also assume that you know basic programming/PHP paradigms

OK lets get started, what you’ll want to do first is to create a simple filter, I’ll be using the twitter-search publisher for this. So lets say you wanted to get all of the tweets that have the keywords “@mikeluby”, “mike luby”, and “mikeluby.com”. You would start by creating the filter, lets name it “aboutMikeLuby” next you’ll want to put the URL to your callback (lets use http://example.com/gnip_input.php). Finally at the bottom you’ll enter the keywords into the keyword input. This input is comma separated and will simulate an OR conditionals to the twitter search api. Now there is away to create these filters via code, I’ll get into this at a later date. When the activities are returned they are grouped into buckets, there is a new bucket every minute.

At this point you’ll want to make sure you have the Gnip PHP Convenience Library downloaded. (Get it here) In gnip_input.php (the callback when gnip “pushes” data to your service) you’ll have the following:


//This file is called every time Gnip has activities to publish to the current bucket.

include_once( "Gnip.php" );

$time = time(); //Get current time

$gnip = new Services_Gnip( $gnip_username, $gnip_password ); //Create gnip Object

$filter = $gnip->getFilter( "twitter-search", "aboutMikeLuby" ); //Create filter object

$results = $gnip->getFilterActivities( "twitter-search", $filter, $time ); //This returns a Services_Gnip Object of the activites in the specified bucket.

print_r( $results );

There you go, it’s pretty straight forward. Don’t forget to check out Gnip’s documentation.

February 25th, 2009 | Categories: Ignite Phoenix, Live

Tonight is Ignite Phoenix #3 hosted at the Tempe Center for the Arts. For those who don’t know what Ignite Phoenix is all about: “Ignite Phoenix is an information exchange aimed at fostering and inspiring Phoenix’s creative community. Presenters get 5 minutes and 20 slides to talk about anything they are passionate about. Send in your presentation or just show up and have a fun time.” If you’re in town there is still plenty of time to RSVP to the event either via the Facebook Event or at Upcoming. Don’t forget to join Ignite Phoenix’s Facebook group and LinkedIn Group. I expect there will be quite a bit of useful information and networking going on at this event.

Below I’ll be sharing the event live here and also via my twitter. Feel free to refresh the page as much as you would like It’ll be updated as much as possible through out the evening.

Update: The videos are now online http://ignitephoenix.blip.tv/ go check them all out.

Live Blogging:
View the live feed at http://ignite-phoenix.org/live/

5:14 – I arrived at TCA the event doesn’t start until 6

More after the fold…
Read more…

February 19th, 2009 | Categories: Facebook

Facebook has just launched their first social widget using their increasingly popular Facebook Connect platform. You can take a look at their recent blog post to explain it a little more. Facebook says that “Sites have seen as much as 40-50% more comments since they launched added these features.” and adding Facebook connect to a site is extremely easy.  I’m not going to go over how to implement Facebook connect right now (maybe later). Using a mix of the Facebook PHP API and Facebook connect you can totally replace your own blog’s comment system. I invite you to check out the comment system in action here.

Below the fold I’m going to paste a code snippet that will set you on your way.

Read more…

January 11th, 2009 | Categories: twitter

If you find your self not truly satisfied with filling out a form or by sending a text you can post your twitter statuses via command line/curl:

curl -u USERNAME:PASSWORD -d status="MESSAGE" http://twitter.com/statuses/update.xml | grep truncated
October 15th, 2008 | Categories: Actionscript

What this code snippet allows is the ability to pass the number of seconds and return a simple time stamp in the form of “Weeks:Days:Hours:Minutes:Seconds” with the minimum return of “Minutes:Seconds”. A good use of this snippet is in media players to convert the duration of the media to a more readable time stamp.

/**
* Converts seconds to minutes and seconds
* @param number Number of seconds
* @return String of minutes and seconds (00:00)
*/
public function convertTime( number:Number ):String {
	number = Math.abs( number );
	var val:Array = new Array( 5 );
		val[ 0 ] = Math.floor( number / 86400 / 7 ); //weeks
		val[ 1 ] = Math.floor( number / 86400 % 7 );//days
		val[ 2 ] = Math.floor( number / 3600 % 24 );//hours
		val[ 3 ] = Math.floor( number / 60 % 60 );//mins
		val[ 4 ] = Math.floor( number % 60 );//secs
	var stopage:Boolean = false;
	var cutIndex:Number  = -1;
	for(var i:Number = 0; i < val.length; i++ ) {
		if( val[ i ] < 10 )
			val[ i ] = "0" + val[ i ];
		if( val[ i ] == "00" && i < ( val.length - 2 ) && !stopage ) {
			cutIndex = i;
		} else {
			stopage = true;
		}
	}
	val.splice( 0, cutIndex + 1 );
	return val.join( ":" );
}
September 29th, 2008 | Categories: PHP

Here is a quick code snippet to use the tinyurl link creation api.

< ?php
//tinyURL function, needs url to be passed to tinyrul
function tinyURL( $url ) {
	//Initializes a new session and return a cURL handle
	$curl = curl_init( );
	//Sets an option on the given cURL session handle.
	//request url
	curl_setopt( $curl, CURLOPT_URL, "http://tinyurl.com/api-create.php?url=" . urlencode( $url ) );
	curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 ); //return transfer
	curl_setopt( $curl, CURLOPT_CONNECTTIMEOUT, 10 ); // connection timeout
	//Execute the given cURL session.
	$tiny = curl_exec( $curl );
	//Closes a cURL session and frees all resources. The cURL handle, $curl , is also deleted.
	curl_close( $curl );
	//return result from curl
	return( $tiny );
}

echo tinyURL( "http://strategicv.com/" ); //echos: http://tinyurl.com/3r4j8c
?>
April 18th, 2008 | Categories: Social Media

What is social media Social media marketing is sometimes hard to describe but you know what it is when you see it. Today millions of people are connected through social networks such as Myspace and Facebook. Social media marketing allows brands to use social technologies such as blogs, interactive websites, and video, just to name a few, to entice users to contribute to the brand’s messaging creating their own buzz about the brand. Users virally spread their messages through the use of the social media technologies. These like-minded individuals build their own communities around the brands they like and use. Through the use of these technologies a greater percentage of the brand’s target audience can now be reached, tracked and serviced. I guess in a way social media marketing puts the power in the hands of the users and in turn the users basically do the rest of the work for the brands.

http://theanswer.ad-tech.com/view/answer/What-is-social-media-marketing-6

TOP