Chat on Pusher
Pusher ã使ã£ã¦ãã£ããã¢ããªãä½ã£ããã³ã¬ â http://chatto.heroku.com/ãããã¯ã¨ã³ãã¯ç¸å¤ããã SinatraãTwitter ã®ã¢ã«ã¦ã³ãã使ã£ã¦ãã£ãããã§ããããã£ããã®å
容ããã¤ã¼ããããããæ©è½ã¯ãªãã
Pusher å¨ã㯠Pusher ã®ãµã¤ãã« Demo ã¨ãã¦æ²è¼ããã¦ãã Pusher Chat ããTwitter å¨ã㯠jugyo ããã® Twiwt:Chat ãåèã«ããã¦ããã ãããã£ã¦ãã¾ããã
ä½ã£ã¦ãã¦ä¸çªå°ã£ãã®ããTwitter ã® screen name ã®åå¾æ¹æ³ãåããªãã£ããã¨ãTwitter é¢é£ã®ã©ã¤ãã©ãªã¯ gem ã® Twitter ã使ç¨ãã¦ãããOAuth ã®èªè¨¼ã¯ã§ãã¦ããããããèªåã® screen name ãã¨ããªãã£ãã
åèã«ããã¦ããã ãã Twiwt:Chat (Python) ã§ã¯ screen name ã¯åå¾ã§ãã¦ããã®ã§ãTwitter ã® API ããã¨ããªãã¨ãããã¨ã¯ãªãããã ã£ããã©ããã£ã¦åå¾ãã¦ããã®ã ããã¨ã½ã¼ã¹ãè¦ãã¨ãã©ãã この辺り ã該å½ç®æã®ããã ã
gem ã® Twitter ã§ããã«å¯¾å¿ãã¦ãã®ã ここ ãããã® access_token ããã³ããã¦ã¿ãã¨
#<OAuth::AccessToken:0x2b8fda1a4e48 ... @params= {:oauth_token=>"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", :user_id=>"0000000000", "oauth_token_secret"=>"yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy", :screen_name=>"yamamucho", "user_id"=>"0000000000", :oauth_token_secret=>"yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy", "oauth_token"=>"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "screen_name"=>"yamamucho"}, ...
@params ã« screen name ã ã«å
¥ã£ã¦ããã¨ãããã¨ãããã£ãã
ã®ã§ã次ã®ããã«ã㦠get_access_token ã®æ»ãå¤ãã¡ã³ãã«ä¿åãã¦ããããã«ããããã㧠@access_token.params[:screen_name] ã¨ãã§ãscreen name ãåå¾ã§ããã
class Twitter::OAuth def authorize_from_request(rtoken, rsecret, verifier_or_pin) request_token = ::OAuth::RequestToken.new(signing_consumer, rtoken, rsecret) @access_token = request_token.get_access_token(:oauth_verifier => verifier_or_pin) @atoken, @asecret = @access_token.token, @access_token.secret end end
ãããªå¯¾å¿ã§ããã®ããããä»ã®é¨åã«å½±é¿ã¯ã§ãªãã®ãï¼ã¨ããããèªåã使ãæ©è½ã ãã§ããã°åé¡ã¯åºã¦ããªããã©ã
11/23 追è¨
githubã«ã½ã¼ã¹ãupãããhttps://github.com/ymmtmsys/chatto