Updated to new twitter lib.

This commit is contained in:
Martin Edenhofer 2013-11-19 10:05:40 +01:00
parent 14ae7b73b9
commit b9dc843101
2 changed files with 28 additions and 28 deletions

View file

@ -4,12 +4,12 @@ require 'twitter'
class Channel::Twitter2
def connect(channel)
@client = Twitter::Client.new(
:consumer_key => channel[:options][:consumer_key],
:consumer_secret => channel[:options][:consumer_secret],
:oauth_token => channel[:options][:oauth_token],
:oauth_token_secret => channel[:options][:oauth_token_secret]
)
@client = Twitter::REST::Client.new do |config|
config.consumer_key = channel[:options][:consumer_key]
config.consumer_secret = channel[:options][:consumer_secret]
config.access_token = channel[:options][:oauth_token]
config.access_token_secret = channel[:options][:oauth_token_secret]
end
end
def fetch (channel)
@ -265,15 +265,15 @@ class Channel::Twitter2
# logger.debug('tweeeeettttt!!!!!!')
channel = Channel.where( :area => 'Twitter::Inbound', :active => true ).first
client = Twitter::Client.new(
:consumer_key => channel[:options][:consumer_key],
:consumer_secret => channel[:options][:consumer_secret],
:oauth_token => channel[:options][:oauth_token],
:oauth_token_secret => channel[:options][:oauth_token_secret]
)
client = Twitter::REST::Client.new do |config|
config.consumer_key = channel[:options][:consumer_key]
config.consumer_secret = channel[:options][:consumer_secret]
config.access_token = channel[:options][:oauth_token]
config.access_token_secret = channel[:options][:oauth_token_secret]
end
if attr[:type] == 'twitter direct-message'
puts 'to:' + attr[:to].to_s
dm = client.direct_message_create(
dm = client.create_direct_message(
attr[:to].to_s,
attr[:body].to_s,
{}

View file

@ -1,6 +1,6 @@
# encoding: utf-8
require 'test_helper'
class TwitterTest < ActiveSupport::TestCase
# app config
@ -85,12 +85,12 @@ class TwitterTest < ActiveSupport::TestCase
sleep 10
# reply by me_bauer
client = Twitter::Client.new(
:consumer_key => consumer_key,
:consumer_secret => consumer_secret,
:oauth_token => user2_token,
:oauth_token_secret => user2_token_secret
)
client = Twitter::REST::Client.new do |config|
config.consumer_key = consumer_key
config.consumer_secret = consumer_secret
config.access_token = user2_token
config.access_token_secret = user2_token_secret
end
tweets = client.search( hash )
tweets.results.map do |tweet|
assert_equal( tweet.id, article.message_id )
@ -119,19 +119,19 @@ class TwitterTest < ActiveSupport::TestCase
test 'new by direct message inbound' do
# cleanup direct messages of system
client = Twitter::Client.new(
:consumer_key => consumer_key,
:consumer_secret => consumer_secret,
:oauth_token => user1_token,
:oauth_token_secret => user1_token_secret
)
client = Twitter::REST::Client.new do |config|
config.consumer_key = consumer_key
config.consumer_secret = consumer_secret
config.access_token = user1_token
config.access_token_secret = user1_token_secret
end
dms = client.direct_messages( :count => 200 )
dms.each {|dm|
client.direct_message_destroy(dm.id)
}
# direct message to @armin_theo
client = Twitter::Client.new(
client = Twitter::REST::Client.new(
:consumer_key => consumer_key,
:consumer_secret => consumer_secret,
:oauth_token => user2_token,
@ -183,4 +183,4 @@ class TwitterTest < ActiveSupport::TestCase
sleep 10
end
end
end