gemTwitter: qualche problemino

Come da titolo, vorrei lavorare con la gemma Twitter. Ora, questo è uno
script (copiato da html.it) presente nella guida. Vorrei chiedere a voi
perchè non funziona

require ‘rubygems’
require ‘twitter’

Twitter::Client.configure do |conf|
conf.protocol = :ssl
conf.host = ‘twitter.com
conf.port = 443
conf.user_agent = ‘RubyTwitter’
conf.application_name = ‘RubyTwitterApp’
conf.application_version = ‘v0.0.1’
end

user = “username”
pwd = “password”
client = Twitter::Client.new(:login => user, :password => pwd)

Fino a qui tutto bene, il problema ce l’ho con questa istruzione

msg_status = client.status(:post, “Just a post from my RubyTwitterApps”)

Che cosa mi potete dire?!

Il 25/04/2011 11:14, Andrea R. ha scritto:

conf.port = 443

msg_status = client.status(:post, “Just a post from my RubyTwitterApps”)

Che cosa mi potete dire?!

che errore ricevi?

A.

Aggiornamenti=> Ho aggiornato Ruby dalla 1.8.7 (distro fedora) alla
1.9.2 scompattando il pacchetto. ripetendo lo stesso script, ecco
l’errore infame:
irb SendTweet.rb
SendTweet.rb(main):001:0> require ‘rubygems’
=> false
SendTweet.rb(main):002:0> require ‘twitter’
=> true
SendTweet.rb(main):003:0>
SendTweet.rb(main):004:0* Twitter::Client.configure do |conf|
SendTweet.rb(main):005:1* conf.protocol = :ssl
SendTweet.rb(main):006:1> conf.host = ‘twitter.com
SendTweet.rb(main):007:1> conf.port = 443
SendTweet.rb(main):008:1> conf.user_agent = ‘RubyTwitter’
SendTweet.rb(main):009:1> conf.application_name = ‘RubyTwitterApp’
SendTweet.rb(main):010:1> conf.application_version = ‘v0.0.1’
SendTweet.rb(main):011:1> end
NoMethodError: undefined method configure' for Twitter::Client:Class from SendTweet.rb:4 from /usr/local/bin/irb:12:in
SendTweet.rb(main):012:0>
SendTweet.rb(main):013:0* user = “xxxxxxxxxxxxx”
=> “masterthebest”
SendTweet.rb(main):014:0> pwd = “xxxxxxxxxxx”
=> “rossithebest88”
SendTweet.rb(main):015:0> client = Twitter::Client.new(:login => user,
:password => pwd)
=> #<Twitter::Client:0x9aaef34 @adapter=:net_http, @consumer_key=nil,
@consumer_secret=nil, @endpoint=“https://api.twitter.com/1/”,
@format=:json, @oauth_token=nil, @oauth_token_secret=nil, @proxy=nil,
@search_endpoint=“https://search.twitter.com/”, @user_agent=“Twitter
Ruby Gem 1.4.0”>
SendTweet.rb(main):016:0> #Fino a qui tutto bene, il problema ce l’ho
con questa istruzione
SendTweet.rb(main):017:0* msg_status = client.status(:post, “Just a post
from my RubyTwitterApps”)
Warning: no such file to load – net/https. Make sure openssl is
installed if you want ssl support
NoMethodError: undefined method each' for "Just a post from my RubyTwitterApps":String from /usr/local/lib/ruby/gems/1.9.1/gems/faraday-0.6.1/lib/faraday/utils.rb:77:inmerge_params’
from
/usr/local/lib/ruby/gems/1.9.1/gems/faraday-0.6.1/lib/faraday/request.rb:70:in
to_env_hash' from /usr/local/lib/ruby/gems/1.9.1/gems/faraday-0.6.1/lib/faraday/request.rb:87:inrun’
from
/usr/local/lib/ruby/gems/1.9.1/gems/faraday-0.6.1/lib/faraday/request.rb:28:in
run' from /usr/local/lib/ruby/gems/1.9.1/gems/faraday-0.6.1/lib/faraday/connection.rb:170:inrun_request’
from
/usr/local/lib/ruby/gems/1.9.1/gems/faraday-0.6.1/lib/faraday/connection.rb:64:in
get' from /usr/local/lib/ruby/gems/1.9.1/gems/twitter-1.4.0/lib/twitter/request.rb:28:inrequest’
from
/usr/local/lib/ruby/gems/1.9.1/gems/twitter-1.4.0/lib/twitter/request.rb:6:in
get' from /usr/local/lib/ruby/gems/1.9.1/gems/twitter-1.4.0/lib/twitter/client/tweets.rb:19:instatus’
from SendTweet.rb:17
from /usr/local/bin/irb:12:in `’

Grazie a tutti voi per il vostro supporto!!!

Ciao,
Forse può esserti utile la gemma TWT (gem install twt) che trovi anche
su github: https://github.com/pbosetti/twt

Ciao,
Paolo

Ciao Andrea occhio che non hai installato qualche pezzo legato ad
openssl (ti dice che non riesce a caricare http/ssl).

Altra cosa, twitter ha disabilitato il supporto per autenticarsi con
user e pwd attraverso le API.
La tua applicazione deve essere censita su twitter (vai su
dev.twitter.com per registrare la tua app) e poi devi usare OAuth per
poterti integrare.

HTH

Ciao ciao
Paolo

“static analysis is fun… again”
Owasp Orizon project leader: http://orizon.sf.net
Owasp Italy R&D director

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs