| Kind of class: | public class |
|---|---|
| Package: | fr.blanchonvincent.twitter |
| Inherits from: | EventDispatcher |
| Classpath: | fr.blanchonvincent.twitter.Twitter |
| File last modified: | Sunday, 01 November 2009, 13:05:30 |
This is a simple Twitetr API
----------------------------------------------------------
To use your account
{{{
var t : Twitter = new Twitter();
// Log in with your account
t.logIn( "username" , "pmypassword" );
// To use defaul php proxy to load XML information (more information at *** PHP PROXY *** section)
t.useDefaultProxy();
// To know when the login is complete
t.addEventListener( TwitterResponseEvent.LOGIN_SUCCESS, success );
function success( e:TwitterResponseEvent ):void {
// To twitt
t.twitt( "My new statut" );
// To delete last twitt
t.untwitt();
// To follow a friend
t.follow( "blanchonvincent" );
// To unfollow a friend
t.unfollow( "blanchonvincent" );
}
}}}
You can add eventListener on twitt(), follow(), etc ... :
{{{
function success( e:TwitterResponseEvent ):void {
// To twitt
t.twitt( "My new statut" );
t.addEventListener( TwitterResponseEvent.TWITT_SUCCESS, twittSuccess );
t.addEventListener( TwitterResponseEvent.TWITT_ERROR, twittError );
// To follow a friend (use ID)
t.follow( "blanchonvincent" );
t.addEventListener( TwitterResponseEvent.FOLLOW_SUCCESS, followSucess );
t.addEventListener( TwitterResponseEvent.FOLLOW_ERROR, followError );
etc ...
}
}}}
/!\ If you use logIn, you can use all extract method ( extract, dynamicExtract, etc ... )
----------------------------------------------------------
To use public information of anybody
{{{
var t : Twitter = new Twitter();
// To use defaul php proxy to load XML information (more information at *** PHP PROXY *** section)
t.useDefaultProxy();
// use a twitter account
t.logPublic( "myfriend" );
// To load followers datas
t.load( new Follower() );
// To know when the extract is complete
t.addEventListener( TwitterFileEvent.COMPLETE, complete );
function complete( e:TwitterFileEvent ):void {
// Trace all xml
trace( e.xml );
// To extract screen name of the "myfriends" account followers - this extract use the proxy define with load() : new Follower() here
var followers_screen_name:XMLList = e.currentTarget.extract( Follower.SCREEN_NAME );
// To extract name of the "myfriends" account followers - this extract use the proxy define with load() : new Follower() here
var followersname:XMLList = e.currentTarget.extract( Follower.NAME );
}
}}}
/!\ With logPublic you can't use private account method : twitt(), follow(), ... you must log with logIn()
----------------------------------------------------------
To use a proxy and extract method without saving (a default proxy) proxy with load, use dynamicExtract :
{{{
var t : Twitter = new Twitter();
// To use defaul php proxy to load XML information (more information at *** PHP PROXY *** section)
t.useDefaultProxy();
// use a twitter account
t.logPublic( 'myfriend' );
// Use dynamicExtract to use several proxy (User(), UserTimeline() ...), event dispatched is a TwitterEvent and not TwitterFileEvent
t.dynamicExtract( new User(), User.FOLLOWERS_COUNT );
t.dynamicExtract( new UserTimeline(), UserTimeline.STATUS );
t.dynamicExtract( new Followers(), Followers.SCREEN_NAME );
t.addEventListener( TwitterEvent.EXTRACT, complete );
function complete( e:TwitterEvent ):void {
// dynamic extract use User framework
if ( e.proxy is User ) {
...
trace( e.xml ); -----> ... dynamic extract information (XMLList) ...
ex with t.dynamicExtract( new User(), User.FOLLOWERS_COUNT ) :
trace( e.xml ) ----->113
trace( e.xml.followers_count ) -----> 113
}
else if ( e.proxy is Followers ) { ... }
...
}
}}}
----------------------------------------------------------
** PHP PROXY ***
To use method 'twitt', 'logIn', etc ... all methods which run with your account information (login and password) runs with php files. You can use default php files (in my webserver)
but you can copy and paste the php files in your server and modify constantes URL_CONNEXION, URL_TWITT, URL_FOLLOW, URL_UNTWITT, URL_UNFOLLOW, URL_PROXY in Twitter.as or with :
Twitter.URL_CONNEXION = " http://www.myserver.com/connexion.php" etc ...
If you are AS3 or PHP beginners, you can use my php files.
For few connexions, you can use default url on my website. Nothing informationslo(login, password etc ...) is save. It's safe.
More informations and help to : blanchon[dot]vincent[at]gmail[dot]com or on my website : http://www.blanchon-vincent.fr/
Twitter with your account works with PHP Zend Framework. All php files are available in the api.zip in fr.blanchonvincent/twitter/php/files.zip.
** PROXY PHP - XML LOADER and define crossdomain ***
Use 'public function addSecurity( crossdomain:String, phpFile:String ):void' method :
{{{
t:Twitter = new Twitter();
// To define php proxy
t.defineSecurity( null, 'http://www.myserver.com/loadXML.php');
// To define crossdomain
t.defineSecurity( 'http:/www.twitter.com/crossdomain.xml', null );
// To add php proxy
t.addSecurity( new XMLReaderSecurity( null, 'http://www.myserver.com/loadXML.php' ) );
// To add crossdomain
t.addSecurity( new XMLReaderSecurity( 'http:/www.twitter.com/crossdomain.xml', null ) );
}}}
** GENRAL INFORMATION ***
Twitter.as works with XMLReader. XMLReader is a XML reader framework. It's simple and available in the general framework : http://www.blanchon-vincent.fr/wp-content/works/as3library.zip or http://www.blanchon-vincent.fr/actionscript/ to read framework description
----------------------------------------------------------
To use your account
{{{
var t : Twitter = new Twitter();
// Log in with your account
t.logIn( "username" , "pmypassword" );
// To use defaul php proxy to load XML information (more information at *** PHP PROXY *** section)
t.useDefaultProxy();
// To know when the login is complete
t.addEventListener( TwitterResponseEvent.LOGIN_SUCCESS, success );
function success( e:TwitterResponseEvent ):void {
// To twitt
t.twitt( "My new statut" );
// To delete last twitt
t.untwitt();
// To follow a friend
t.follow( "blanchonvincent" );
// To unfollow a friend
t.unfollow( "blanchonvincent" );
}
}}}
You can add eventListener on twitt(), follow(), etc ... :
{{{
function success( e:TwitterResponseEvent ):void {
// To twitt
t.twitt( "My new statut" );
t.addEventListener( TwitterResponseEvent.TWITT_SUCCESS, twittSuccess );
t.addEventListener( TwitterResponseEvent.TWITT_ERROR, twittError );
// To follow a friend (use ID)
t.follow( "blanchonvincent" );
t.addEventListener( TwitterResponseEvent.FOLLOW_SUCCESS, followSucess );
t.addEventListener( TwitterResponseEvent.FOLLOW_ERROR, followError );
etc ...
}
}}}
/!\ If you use logIn, you can use all extract method ( extract, dynamicExtract, etc ... )
----------------------------------------------------------
To use public information of anybody
{{{
var t : Twitter = new Twitter();
// To use defaul php proxy to load XML information (more information at *** PHP PROXY *** section)
t.useDefaultProxy();
// use a twitter account
t.logPublic( "myfriend" );
// To load followers datas
t.load( new Follower() );
// To know when the extract is complete
t.addEventListener( TwitterFileEvent.COMPLETE, complete );
function complete( e:TwitterFileEvent ):void {
// Trace all xml
trace( e.xml );
// To extract screen name of the "myfriends" account followers - this extract use the proxy define with load() : new Follower() here
var followers_screen_name:XMLList = e.currentTarget.extract( Follower.SCREEN_NAME );
// To extract name of the "myfriends" account followers - this extract use the proxy define with load() : new Follower() here
var followersname:XMLList = e.currentTarget.extract( Follower.NAME );
}
}}}
/!\ With logPublic you can't use private account method : twitt(), follow(), ... you must log with logIn()
----------------------------------------------------------
To use a proxy and extract method without saving (a default proxy) proxy with load, use dynamicExtract :
{{{
var t : Twitter = new Twitter();
// To use defaul php proxy to load XML information (more information at *** PHP PROXY *** section)
t.useDefaultProxy();
// use a twitter account
t.logPublic( 'myfriend' );
// Use dynamicExtract to use several proxy (User(), UserTimeline() ...), event dispatched is a TwitterEvent and not TwitterFileEvent
t.dynamicExtract( new User(), User.FOLLOWERS_COUNT );
t.dynamicExtract( new UserTimeline(), UserTimeline.STATUS );
t.dynamicExtract( new Followers(), Followers.SCREEN_NAME );
t.addEventListener( TwitterEvent.EXTRACT, complete );
function complete( e:TwitterEvent ):void {
// dynamic extract use User framework
if ( e.proxy is User ) {
...
trace( e.xml ); ----->
ex with t.dynamicExtract( new User(), User.FOLLOWERS_COUNT ) :
trace( e.xml ) ----->
trace( e.xml.followers_count ) -----> 113
}
else if ( e.proxy is Followers ) { ... }
...
}
}}}
----------------------------------------------------------
** PHP PROXY ***
To use method 'twitt', 'logIn', etc ... all methods which run with your account information (login and password) runs with php files. You can use default php files (in my webserver)
but you can copy and paste the php files in your server and modify constantes URL_CONNEXION, URL_TWITT, URL_FOLLOW, URL_UNTWITT, URL_UNFOLLOW, URL_PROXY in Twitter.as or with :
Twitter.URL_CONNEXION = " http://www.myserver.com/connexion.php" etc ...
If you are AS3 or PHP beginners, you can use my php files.
For few connexions, you can use default url on my website. Nothing informationslo(login, password etc ...) is save. It's safe.
More informations and help to : blanchon[dot]vincent[at]gmail[dot]com or on my website : http://www.blanchon-vincent.fr/
Twitter with your account works with PHP Zend Framework. All php files are available in the api.zip in fr.blanchonvincent/twitter/php/files.zip.
** PROXY PHP - XML LOADER and define crossdomain ***
Use 'public function addSecurity( crossdomain:String, phpFile:String ):void' method :
{{{
t:Twitter = new Twitter();
// To define php proxy
t.defineSecurity( null, 'http://www.myserver.com/loadXML.php');
// To define crossdomain
t.defineSecurity( 'http:/www.twitter.com/crossdomain.xml', null );
// To add php proxy
t.addSecurity( new XMLReaderSecurity( null, 'http://www.myserver.com/loadXML.php' ) );
// To add crossdomain
t.addSecurity( new XMLReaderSecurity( 'http:/www.twitter.com/crossdomain.xml', null ) );
}}}
** GENRAL INFORMATION ***
Twitter.as works with XMLReader. XMLReader is a XML reader framework. It's simple and available in the general framework : http://www.blanchon-vincent.fr/wp-content/works/as3library.zip or http://www.blanchon-vincent.fr/actionscript/ to read framework description
Summary
Constructor
Class properties
- URL_CONNEXION : String
- URL_TWITT : String
- URL_UNTWITT : String
- URL_FOLLOW : String
- URL_UNFOLLOW : String
- URL_PROXY : String
Instance properties
- publicLogged : Boolean
- To get public log
- username : String
- To get user username (login account)
- id : String
- To get your ID
Instance methods
- logIn (id:String, pass:String) : void
- To logIn your account
- logPublic (id:String) : void
- To log a publci twitter account
- useDefaultProxy : void
- To use default PHP proxy to read Twitter
- defineSecurity (crossdomain:String, phpFile:String) : void
- To define a crossdomain or define a mendataire PHP file
- addSecurity (security:XMLReaderSecurity) : void
- To add a crossdomain or define a mendataire PHP file
- load (proxy:Proxy) : void
- To load an xml.
- twitt (message:String) : void
- To twitt on your account
- untwitt : void
- To twitt on your account
- follow (user:String) : void
- To follow a friends
- unfollow (user:String) : void
- To leave follow a friends
- extract (func:String) : XMLList
- To extract XML proxy by filters.
- dynamicExtract (proxy:Proxy, func:String) : XMLList
- To extract XML with a dynamic proxy.
- toString : String
Constructor
public function Twitter (
)
Class properties
URL_CONNEXION
public static URL_CONNEXION:String = "http://www.blanchon-vincent.fr/wp-content/library/twitter/connexion.php"
(read,write)
URL_FOLLOW
public static URL_FOLLOW:String = "http://www.blanchon-vincent.fr/wp-content/library/twitter/follow.php"
(read,write)
URL_PROXY
public static URL_PROXY:String = "http://www.blanchon-vincent.fr/wp-content/library/twitter/loadXML.php"
(read,write)
URL_TWITT
public static URL_TWITT:String = "http://www.blanchon-vincent.fr/wp-content/library/twitter/twitt.php"
(read,write)
URL_UNFOLLOW
public static URL_UNFOLLOW:String = "http://www.blanchon-vincent.fr/wp-content/library/twitter/unfollow.php"
(read,write)
URL_UNTWITT
public static URL_UNTWITT:String = "http://www.blanchon-vincent.fr/wp-content/library/twitter/untwitt.php"
(read,write)
Instance properties
id
public id:String
(read,write)
To get your ID
publicLogged
public publicLogged:Boolean
(read)
To get public log
username
public username:String
(read)
To get user username (login account)
Instance methods
addSecurity
To add a crossdomain or define a mendataire PHP file
defineSecurity
public function defineSecurity (
crossdomain:String,
phpFile:String) : void
To define a crossdomain or define a mendataire PHP file
dynamicExtract
To extract XML with a dynamic proxy. Use proxy classes constant to define filter.
extract
public function extract (
func:String) : XMLList
To extract XML proxy by filters. Use proxy classes constant to define filter.
follow
public function follow (
user:String) : void
To follow a friends
load
To load an xml. Use Twitter constants to fill the request.
logIn
public function logIn (
id:String,
pass:String) : void
To logIn your account
logPublic
public function logPublic (
id:String) : void
To log a publci twitter account
toString
override public function toString (
) : String
Overrides:
- EventDispatcher.toString
twitt
public function twitt (
message:String) : void
To twitt on your account
unfollow
public function unfollow (
user:String) : void
To leave follow a friends
untwitt
public function untwitt (
) : void
To twitt on your account
useDefaultProxy
public function useDefaultProxy (
) : void
To use default PHP proxy to read Twitter