Join Login


Video Tutorials
Blog



Stock Photos from 123RF

Twitter API (Part1)


By: RiverCityGraphix      Views: 3416      Share: Bookmark and Share

In this tutorial, you will learn how bring Tweets into Flash using the Twitter API.

Twitter is growing in popularity everyday. Many website owners are creating Twitter accounts to try and draw in more traffic and connect with users on another level. With this in mind, you may want to add a feed of your most recent Tweets to your site. This can be done with both Flash and coding languages like PHP. The benefit of using Flash is that you can animate the tweets and display them in a more interesting way that just text. This tutorial gives you the basis you will need to create your own Twitter Application in Flash.

Check out part two: Twitter API (Part2)

Actionscript 3.0
stop();

import flash.net.URLRequest;
import flash.net.URLLoader;

var i:URLLoader = new URLLoader();
i.addEventListener(Event.COMPLETE, loaded);
i.load(new URLRequest("http://www.rivercitygraphix.com/scripts/twitterphpfile.php"));

function loaded(e:Event):void{
	e.currentTarget.removeEventListener(Event.COMPLETE, loaded);
	var xml:XML = new XML(e.currentTarget.data);
	var list:XMLList = new XMLList(xml.status.text);
	box.text = list[0];
}


PHP
<?php
$xmldata = 'http://twitter.com/statuses/user_timeline.xml?screen_name=RiverCityGraphx';
$open = fopen($xmldata, 'r');
$content = stream_get_contents($open);
fclose($open);
echo $content;
?>




Free Source Files Zip