Ver Mensaje Individual
  #2 (permalink)  
Antiguo 03/06/2015, 08:24
Madh
 
Fecha de Ingreso: octubre-2013
Mensajes: 44
Antigüedad: 10 años, 5 meses
Puntos: 5
Respuesta: Duda con la Gema de Twitter en ruby

Para empezar, este tutorial está bastante bien: http://www.codecademy.com/en/tracks/twitter

Aquí el ejemplo de como enviar un tweet:

Código Ruby:
Ver original
  1. require 'rubygems'
  2. require 'oauth'
  3. require 'json'
  4.  
  5. # You will need to set your application type to
  6. # read/write on dev.twitter.com and regenerate your access
  7. # token.  Enter the new values here:
  8. consumer_key = OAuth::Consumer.new(
  9.   "CONSUMER_KEY",
  10.   "CONSUMER_SECRET")
  11. access_token = OAuth::Token.new(
  12.   "ACCESS_TOKEN",
  13.   "ACCESS_TOKEN_SECRET")
  14.  
  15. # Note that the type of request has changed to POST.
  16. # The request parameters have also moved to the body
  17. # of the request instead of being put in the URL.
  18. baseurl = "https://api.twitter.com"
  19. path    = "/1.1/statuses/update.json"
  20. address = URI("#{baseurl}#{path}")
  21. request = Net::HTTP::Post.new address.request_uri
  22. request.set_form_data(
  23.   "status" => "Hola! soy un tweet!",
  24. )
  25.  
  26. # Set up HTTP.
  27. http             = Net::HTTP.new address.host, address.port
  28. http.use_ssl     = true
  29. http.verify_mode = OpenSSL::SSL::VERIFY_PEER
  30.  
  31. # Issue the request.
  32. request.oauth! http, consumer_key, access_token
  33. http.start
  34. response = http.request request
  35.  
  36. # Parse and print the Tweet if the response code was 200
  37. tweet = nil
  38. if response.code == '200' then
  39.   tweet = JSON.parse(response.body)
  40.   puts "Successfully sent #{tweet["text"]}"
  41. else
  42.   puts "Could not send the Tweet! " +
  43.   "Code:#{response.code} Body:#{response.body}"
  44. end

Saludos

EDITO: no me di cuenta que te referias explicitamente a la gema, en eso no te puedo ayudar