Adobe AIRã§Twitterã¯ã©ã¤ã¢ã³ããä½ã
ActionScriptã®åå¼·ã®çºã«Twitterã¯ã©ã¤ã¢ã³ããèªä½ãããã¨ãã¦æ«æããæ°æ¥åã§ããããæ¨æ¥ãããªãã¼ã¸ãçºè¦ã
【連載】今からはじめるAIRプログラミング(13) HTTPリクエスト用API - Web上のサービスをローカルアプリに取り込む
ä»åã®è¨äºã¯ãURLRequestã®ããããæ©è½æ¡å¼µã試ããããé常ã«åç´ãªTwitterã®ã¯ã©ã¤ã¢ã³ãããµã³ãã«ã³ã¼ãã¨ãã¦ç¨æããã
ã¡ããã©ããã¨ããã«ï¼
ããã使ã£ã¦ä½ã£ã¦ãã¾ãã®ãæ©ãï¼ã¨ãããã¨ã§ä½ãã¾ãããããããå®è¡ãã¦ã¿ãã¨ãã¦ã¼ã¶ã¼åã¨ãã¹ã¯ã¼ããå
¥åãã¦"ãã°ã¤ã³"ãã¿ã³ãæ¼ããã¨ããã§æ¢ã¾ã£ã¦ãã¾ãã
ãªãã ããï¼ã¨ãããã¨ã§ã¡ããã¨ã½ã¼ã¹ãèªãã§ã¿ããã¨ã«ã
// ãã°ã¤ã³ãã¿ã³æ¼ä¸åã®å¦ç private function login():void { // (1) 以éã®URLRequestãå ¨ã¦èªè¨¼æ å ±ä»ãã§è¡ãããããã«ãããã©ã«ãå¤ã¨ãã¦ã»ãã URLRequestDefaults.setLoginCredentialsForHost("twitter.com", userName.text, password.text); // (2) 以éãTwitterã«HTTPãªã¯ã¨ã¹ããéä¿¡ããå¦ç var req:URLRequest = new URLRequest("http://twitter.com/statuses/update.xml"); // POSTã¡ã½ããã§ãªããã°ãããªã req.method = "POST"; // Twitterã¯æ示çã«èªè¨¼ãè¡ãããã®APIãæä¾ããã¦ããªãã®ã§ã // é·ãã¼ãã®æååã§ã¹ãã¼ã¿ã¹ãå¤æ´ãã¦ã¿ããã¨ã«ãã£ã¦ä»£ç¨ var variables:URLVariables = new URLVariables(); variables.status = ""; // HTTPãªã¯ã¨ã¹ããå®è¡ã var loader:URLLoader = new URLLoader(req); // (3) HTTPã¬ã¹ãã³ã¹ã¤ãã³ããææ loader.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS, onHTTPResponse); }
ããã¦mineã¯æ°ãã¤ãã¾ããã
HTTPãªã¯ã¨ã¹ããå®è¡ããå¾ã«loaderã«ã¬ã¹ãã³ã¹ã¤ãã³ãã®ãªã¹ãã追å ãã¦ãæå³ãªãããããã¼ã®ï¼
ã¨ã
ã¤ã¾ãããªã¯ã¨ã¹ããå®è¡ããåã«ã¬ã¹ãã³ã¹ã¤ãã³ããè£è¶³ãããªã¹ãã追å ããã¹ãã§ã¯ãªããããã
ã£ã¦ãã¨ã§ã³ã¼ãã以ä¸ã®ããã«æ¸ãæãã
// HTTPãªã¯ã¨ã¹ããçæã var loader:URLLoader = new URLLoader(); // (3) HTTPã¬ã¹ãã³ã¹ã¤ãã³ããææ loader.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS, onHTTPResponse); // HTTPãªã¯ã¨ã¹ããå®è¡ã loader.load(req);
ããã§åãããã«ãªãã¾ãããã°ãããã°ãããã
å¾ã¯ãããæ稿ã¨ããåºæ¥ãããã«æ¹è¯ãã¦ããã®ãããæ°ããããï¼
ããæ°æ¥ãä¸è©±ã«ãªã£ã¦ããæ¬ãçµæ§é¢ç½ãã§ããActionScriptã¨JavaScript(âå人çã«ããã«ã¯ãã¾ãèå³ãç¡ã)ãAdobe AIRã«ã¤ãã¦çµæ§ãã£ããå¦ã¶ãã¨ãåºæ¥ã¾ãã
Adobe AIRããã°ã©ãã³ã°ã¬ã¤ã
- ä½è : å¸çå·è±ä¸
- åºç社/ã¡ã¼ã«ã¼: æ¯æ¥ã³ãã¥ãã±ã¼ã·ã§ã³ãº
- çºå£²æ¥: 2007/12/22
- ã¡ãã£ã¢: åè¡æ¬ï¼ã½ããã«ãã¼ï¼
- è³¼å ¥: 1人 ã¯ãªãã¯: 50å
- ãã®ååãå«ãããã° (17件) ãè¦ã