Androidã«ASE (Android Scripting Environment)ãå
¥ãã¦ãã楽ããã¦ã¡ããã¡ããããã£ã¦ããã®ã ãã©、Pythonã«åãããtwitterã¢ã¸ã¥ã¼ã«ãå
¥ã£ã¦ãããã¨ã«æ°ãä»ããã®ã§ä½¿ã£ã¦ã¿ã。
æ®æ®µã¯Android端æ«(HT-03A)ã®Twitterã¯ã©ã¤ã¢ã³ãã¨ãã¦Twidroidã使ã£ã¦ããã®ã ãã©、æåã®ç«ã¡ä¸ãã§ã¿ã¤ã ã©ã¤ã³ãåå¾ãã«è¡ãã®ã§ã¡ãã£ã¨ã ãå¾ ãããã。ãã¾ãæ°ã«ã¯ãªããªããã©、ã¤ã¶ããããµã¯ã£ã¨æ稿ãããã ããªãã¿ã¤ã ã©ã¤ã³åå¾ã¯ç¡é§ãªã®ã§、æ稿å°ç¨ã®ã¹ã¯ãªãããçµãã§ã¿ããã¨ã«ãã。以ä¸ããã®ã³ã¼ãã 。èµ·åããã¨ãã¤ã¢ãã°ãåºãã®ã§ã¤ã¶ãããæ¸ãã¦éä¿¡ããã ãã 。éä¿¡ãå®äºãããç»é¢ã«æ稿ããã¤ã¶ããã表示ããã¦çµäºãã。
# -*- coding: utf-8 -*- import android, twitter droid = android.Android() t = droid.getInput(u"Tweet", u"ãã¾ã©ããã¦ã?")["result"].strip() if t: api = twitter.Api("username", "password") api.PostUpdate(t) droid.makeToast(t)
ããã¯ãã¹ã¦Androidä¸ã§ã³ã¼ãã£ã³ã°ãããã®ã 。çãã、ããããæ°åãããã°æ¸ãã。æ¸ãçµãã£ããããããã®ã¾ã¾ãã¼ã ç»é¢ã«ã·ã§ã¼ãã«ããã¢ã¤ã³ã³ã¨ãã¦ç»é²ããã°ãã。ä»ã«ã、bit.lyã®APIã使ã£ã¦ç縮URLãå®è£ ããã、ãµã¼ãã¹ã¨ãã¦èµ·åãã、ç¹å®ã®ãã¼ã¯ã¼ãã«å¼ã£ããã£ãã¨ãã«Androidã«éç¥ãããã、ã¡ã¼ã«ãéä¿¡ãããããããã¨ãç°¡åã ãã。ãã¯ã、ã¹ã¯ãªããã使ããã¨ããããã§ãã¦é¢ç½ããª。
æ®æ®µã¯Android端æ«(HT-03A)ã®Twitterã¯ã©ã¤ã¢ã³ãã¨ãã¦Twidroidã使ã£ã¦ããã®ã ãã©、æåã®ç«ã¡ä¸ãã§ã¿ã¤ã ã©ã¤ã³ãåå¾ãã«è¡ãã®ã§ã¡ãã£ã¨ã ãå¾ ãããã。ãã¾ãæ°ã«ã¯ãªããªããã©、ã¤ã¶ããããµã¯ã£ã¨æ稿ãããã ããªãã¿ã¤ã ã©ã¤ã³åå¾ã¯ç¡é§ãªã®ã§、æ稿å°ç¨ã®ã¹ã¯ãªãããçµãã§ã¿ããã¨ã«ãã。以ä¸ããã®ã³ã¼ãã 。èµ·åããã¨ãã¤ã¢ãã°ãåºãã®ã§ã¤ã¶ãããæ¸ãã¦éä¿¡ããã ãã 。éä¿¡ãå®äºãããç»é¢ã«æ稿ããã¤ã¶ããã表示ããã¦çµäºãã。
# -*- coding: utf-8 -*- import android, twitter droid = android.Android() t = droid.getInput(u"Tweet", u"ãã¾ã©ããã¦ã?")["result"].strip() if t: api = twitter.Api("username", "password") api.PostUpdate(t) droid.makeToast(t)
ããã¯ãã¹ã¦Androidä¸ã§ã³ã¼ãã£ã³ã°ãããã®ã 。çãã、ããããæ°åãããã°æ¸ãã。æ¸ãçµãã£ããããããã®ã¾ã¾ãã¼ã ç»é¢ã«ã·ã§ã¼ãã«ããã¢ã¤ã³ã³ã¨ãã¦ç»é²ããã°ãã。ä»ã«ã、bit.lyã®APIã使ã£ã¦ç縮URLãå®è£ ããã、ãµã¼ãã¹ã¨ãã¦èµ·åãã、ç¹å®ã®ãã¼ã¯ã¼ãã«å¼ã£ããã£ãã¨ãã«Androidã«éç¥ãããã、ã¡ã¼ã«ãéä¿¡ãããããããã¨ãç°¡åã ãã。ãã¯ã、ã¹ã¯ãªããã使ããã¨ããããã§ãã¦é¢ç½ããª。
ã³ã¡ã³ã
楽ããã§ãããã¦ä½ããã§ã。
droid.startSensing()
sensors = droid.readSensors()
ãããã®APIã§ã»ã³ãµã¼ãããã®ãé¢ç½ãã§ã。
Please check the below URL.
http://handasse.blogspot.com/2010/05/oauthandroidpythontwitter.html