Login
Immutable PageDiscussionInfoAttachments
alstamber/Egofav

MMA

なにこれ

Rubyとか全然わからない件

   1 puts "Hello, World"

とりあえずOAuthしないとね

   1 @consumer=OAuth::Consumer.new( "key","secret", {
   2     :site=>"https://agree2"
   3 })

   1 {:symbol => value,
   2  :symbol => value,
   3  ...
   4 }

   1 OAuth::AccessToken.new(consumer, ACCESS_TOKEN, ACCESS_SECRET)

ふぁぼスクリプトの挙動を考える

Userstreamへの接続

   1 uri = URI.parse("https://userstream.twitter.com/2/user.json")
   2 https = Net::HTTP.new(uri.host, uri.port)
   3 https.use_ssl = true
   4 https.verify_mode = OpenSSL::SSL::VERIFY_NONE
   5 
   6 https.start do |https|
   7     #do something
   8 end

   1 method do |param|
   2  #do something
   3 end

   1 def method
   2  #do something
   3  yield hoge
   4 end

   1 def hoge
   2  yield "test"
   3 end
   4 
   5 hoge do |foo|
   6  puts foo
   7 end

   1 request = Net::HTTP::Get.new(uri.request_uri)
   2 request.oauth!(https, access_token.consumer, access_token)
   3 https.request(request) do |response|
   4  #do something
   5 end

もう少し補足

   1 begin
   2  #something
   3 rescue => e
   4  #something
   5 end

   1 raise "hogehoge" unless fugafuga

   1 OAuth::AccessToken.post(path, body='', headers={})

alstamber/Egofav (last edited 2012-12-10 02:31:08 by alstamber)