Posted By

chrisaiv on 01/04/10


Tagged

twitter as3 swx


Versions (?)

Who likes this?

6 people have marked this snippet as a favorite

adrianparr
TrentSkunk
thehumbledeveloper
zoo
donaldleegraham
tspitzr


AS3: Accessing Twitter User's Public Timeline using SWX


 / Published in: ActionScript 3
 

URL: http://code.google.com/p/swx-format/

I've tried RSS, ATOM, JSON, XML (with a Python Proxy), and so far this is my preferred way to access my Twitter Public Timeline. The project requires you to download the SWX which you can find on Google Code

  1. package
  2. {
  3. import flash.display.Sprite;
  4.  
  5. import org.swxformat.SWX;
  6.  
  7. public class main extends Sprite
  8. {
  9. //http://apiwiki.twitter.com/SWX+Twitter+API
  10. public static const SWX_PUBLIC_GATEWAY:String = "http://www.swxformat.org/php/swx.php";
  11.  
  12. private var currentImage:Number = 0;
  13. private var maxImages:Number = 10;
  14. private var swx:SWX;
  15.  
  16. public function main()
  17. {
  18. swx = new SWX()
  19. swx.gateway = SWX_PUBLIC_GATEWAY;
  20. swx.encoding = "GET";
  21.  
  22. var twitterRequest:Object = {
  23. serviceClass: "Twitter",
  24. method: "userTimeline",
  25. timeout: 5,
  26. //debug: true,
  27. resultHandler: resultHandler,
  28. progressHandler: progressHandler,
  29. timeoutHandler: timeoutHandler,
  30. faultHandler: faultHandler,
  31. //[ "user", "password", "userId", "limit", "since"]
  32. args: [ "chrisaiv", "******", "", "10" ]
  33. };
  34.  
  35. swx.call( twitterRequest );
  36. }
  37.  
  38. private function progressHandler( e:Object ):void
  39. {
  40. //trace( "progressHandler: " + e.bytesLoaded / e.bytesTotal );
  41. }
  42.  
  43. private function timeoutHandler( e:Object ):void
  44. {
  45. trace( "timeoutHandler: " );
  46. }
  47.  
  48. private function faultHandler( e:Object ):void
  49. {
  50. trace( "faultHandler: " + e );
  51. }
  52.  
  53. private function resultHandler( e:Object ):void
  54. {
  55. //Twitter
  56. var data:Array = e.result as Array;
  57. for( var i:Number = 0; i < data.length; i++ ){
  58. var info:Object = data[i] as Object;
  59. trace( "Published: ", info.created_at, "Text:", info.text, "Avatar:", info.user.profile_image_url, "User:", info.user.screen_name );
  60. }
  61. }
  62. }
  63. }

Report this snippet  

You need to login to post a comment.