Commit a8f2b1b7436b0d3e6f48bfd77d07b93552ad36c1
1 parent
6115f53e
Exists in
community_hub_submodule
fixed facebook
Showing
3 changed files
with
20 additions
and
19 deletions
Show diff stats
facebook_stream/lib_facebook_stream.rb
@@ -7,11 +7,12 @@ require 'json' | @@ -7,11 +7,12 @@ require 'json' | ||
7 | #'CAAD8cd4tMVkBAO3sh2DrzwZCDfeQq9ZAvTz7Jz24ZC26KtMfBoljqaXhD2vBV1zpP0bjrpxXUBzJvKKcFzOm6rMG9Sok7iNVUaxt5iwr7dfMqCvHpMboKpqrqgeLrfCH5ITVTAdezA6ZBSr9iOJrqyCSOYfui0zTmbXJ3FqtshwNRrRy4NPH' | 7 | #'CAAD8cd4tMVkBAO3sh2DrzwZCDfeQq9ZAvTz7Jz24ZC26KtMfBoljqaXhD2vBV1zpP0bjrpxXUBzJvKKcFzOm6rMG9Sok7iNVUaxt5iwr7dfMqCvHpMboKpqrqgeLrfCH5ITVTAdezA6ZBSr9iOJrqyCSOYfui0zTmbXJ3FqtshwNRrRy4NPH' |
8 | # BACKUP TOKEN 'CAAEhsewl0ZAcBAHhipXszZCURSwWLmgvceDbs9mB5baJdLriFxYMEzywmF2fvZBuThuA2Mm7QF8wPd3E6R5pVqVEnC2VhcBb4VrfAnkZC73ZC5g1NRUnKZCB2e6CaRiUBDatR2nf505PeKp7Aj5XxvTdfSqdZCsXxQFYZApPNSUUgkUWm6HwL4rp21MRJXb612sZD' | 8 | # BACKUP TOKEN 'CAAEhsewl0ZAcBAHhipXszZCURSwWLmgvceDbs9mB5baJdLriFxYMEzywmF2fvZBuThuA2Mm7QF8wPd3E6R5pVqVEnC2VhcBb4VrfAnkZC73ZC5g1NRUnKZCB2e6CaRiUBDatR2nf505PeKp7Aj5XxvTdfSqdZCsXxQFYZApPNSUUgkUWm6HwL4rp21MRJXb612sZD' |
9 | 9 | ||
10 | -def facebook_comments(hub_id, author_id, page_id="participabr", pooling_time=5, token='CAAD8cd4tMVkBAO3sh2DrzwZCDfeQq9ZAvTz7Jz24ZC26KtMfBoljqaXhD2vBV1zpP0bjrpxXUBzJvKKcFzOm6rMG9Sok7iNVUaxt5iwr7dfMqCvHpMboKpqrqgeLrfCH5ITVTAdezA6ZBSr9iOJrqyCSOYfui0zTmbXJ3FqtshwNRrRy4NPH') | 10 | +def facebook_comments(hub, author_id, page_id="participabr", pooling_time=5, token='CAAD8cd4tMVkBAO3sh2DrzwZCDfeQq9ZAvTz7Jz24ZC26KtMfBoljqaXhD2vBV1zpP0bjrpxXUBzJvKKcFzOm6rMG9Sok7iNVUaxt5iwr7dfMqCvHpMboKpqrqgeLrfCH5ITVTAdezA6ZBSr9iOJrqyCSOYfui0zTmbXJ3FqtshwNRrRy4NPH') |
11 | + | ||
12 | + #raise hub.id.inspect | ||
11 | @graph = Koala::Facebook::API.new(token) | 13 | @graph = Koala::Facebook::API.new(token) |
12 | initialComments = [] | 14 | initialComments = [] |
13 | extractedComments = [] | 15 | extractedComments = [] |
14 | - newComments = [] | ||
15 | firstTime = true | 16 | firstTime = true |
16 | while true | 17 | while true |
17 | feed = @graph.get_connections(page_id, "posts") | 18 | feed = @graph.get_connections(page_id, "posts") |
@@ -24,7 +25,7 @@ def facebook_comments(hub_id, author_id, page_id="participabr", pooling_time=5, | @@ -24,7 +25,7 @@ def facebook_comments(hub_id, author_id, page_id="participabr", pooling_time=5, | ||
24 | } | 25 | } |
25 | array.each{ |comments| | 26 | array.each{ |comments| |
26 | comments.each{|comment| | 27 | comments.each{|comment| |
27 | - extractedComments.push("#{comment['from']['name']} " + _("said:") + " : #{comment['message']}") | 28 | + extractedComments.push("#{comment['from']['name']} " + _("said") + ": #{comment['message']}") |
28 | } | 29 | } |
29 | } | 30 | } |
30 | extractedComments = extractedComments.uniq | 31 | extractedComments = extractedComments.uniq |
@@ -34,12 +35,12 @@ def facebook_comments(hub_id, author_id, page_id="participabr", pooling_time=5, | @@ -34,12 +35,12 @@ def facebook_comments(hub_id, author_id, page_id="participabr", pooling_time=5, | ||
34 | end | 35 | end |
35 | newComments = extractedComments - initialComments | 36 | newComments = extractedComments - initialComments |
36 | newComments = newComments.uniq | 37 | newComments = newComments.uniq |
37 | - initialCommentsinitialComments += newComments | 38 | + initialComments += newComments |
38 | initialComments = initialComments.uniq | 39 | initialComments = initialComments.uniq |
39 | newComments.each{|comment| | 40 | newComments.each{|comment| |
40 | puts comment | 41 | puts comment |
41 | noosferoComment = Comment.new | 42 | noosferoComment = Comment.new |
42 | - noosferoComment.source_id = hub_id | 43 | + noosferoComment.source_id = hub.id |
43 | noosferoComment.body = comment | 44 | noosferoComment.body = comment |
44 | noosferoComment.author_id = author_id | 45 | noosferoComment.author_id = author_id |
45 | noosferoComment.save! | 46 | noosferoComment.save! |
lib/community_hub_plugin/hub.rb
@@ -33,24 +33,24 @@ class CommunityHubPlugin::Hub < Folder | @@ -33,24 +33,24 @@ class CommunityHubPlugin::Hub < Folder | ||
33 | true | 33 | true |
34 | end | 34 | end |
35 | 35 | ||
36 | - def self.twitter_service(page, action) | ||
37 | - author_id = 54 | ||
38 | - if action==:start | ||
39 | - thread = Thread.new { | ||
40 | - Twurl::Stream.run(page, author_id,'torrent', File.dirname(__FILE__) + '/../../tweeter_stream/config/twurlrc') | ||
41 | - } unless@@twitter_thread_started | ||
42 | - @@twitter_thread_started = true | ||
43 | - end | 36 | + def self.twitter_service(hub, action) |
37 | +# author_id = 54 | ||
38 | +# if action==:start | ||
39 | +# thread = Thread.new { | ||
40 | +# Twurl::Stream.run(hub, author_id,'torrent', File.dirname(__FILE__) + '/../../tweeter_stream/config/twurlrc') | ||
41 | +# } unless@@twitter_thread_started | ||
42 | +# @@twitter_thread_started = true | ||
43 | +# end | ||
44 | end | 44 | end |
45 | 45 | ||
46 | - def self.facebook_service(page, action) | 46 | + def self.facebook_service(hub, action) |
47 | author_id = 54 | 47 | author_id = 54 |
48 | page_id="mundoreagindo" | 48 | page_id="mundoreagindo" |
49 | if action==:start | 49 | if action==:start |
50 | - thread = Thread.new { | ||
51 | - #facebook_comments(page, author_id, page_id, pooling_time=5, token='CAAD8cd4tMVkBAO3sh2DrzwZCDfeQq9ZAvTz7Jz24ZC26KtMfBoljqaXhD2vBV1zpP0bjrpxXUBzJvKKcFzOm6rMG9Sok7iNVUaxt5iwr7dfMqCvHpMboKpqrqgeLrfCH5ITVTAdezA6ZBSr9iOJrqyCSOYfui0zTmbXJ3FqtshwNRrRy4NPH') | ||
52 | - facebook_comments(page, author_id, page_id) | ||
53 | - } unless@@facebook_thread_started | 50 | + #facebook_comments(page, author_id, page_id, pooling_time=5, token='CAAD8cd4tMVkBAO3sh2DrzwZCDfeQq9ZAvTz7Jz24ZC26KtMfBoljqaXhD2vBV1zpP0bjrpxXUBzJvKKcFzOm6rMG9Sok7iNVUaxt5iwr7dfMqCvHpMboKpqrqgeLrfCH5ITVTAdezA6ZBSr9iOJrqyCSOYfui0zTmbXJ3FqtshwNRrRy4NPH') |
51 | + thread = Thread.new { | ||
52 | + facebook_comments(hub, author_id, page_id) | ||
53 | + } unless@@facebook_thread_started | ||
54 | @@facebook_thread_started = true | 54 | @@facebook_thread_started = true |
55 | end | 55 | end |
56 | end | 56 | end |
tweeter_stream/lib/twurl/request_controller.rb
@@ -20,7 +20,7 @@ module Twurl | @@ -20,7 +20,7 @@ module Twurl | ||
20 | begin | 20 | begin |
21 | parsed = JSON.parse(chunk) | 21 | parsed = JSON.parse(chunk) |
22 | ic = Iconv.new('UTF-8//IGNORE', 'UTF-8') | 22 | ic = Iconv.new('UTF-8//IGNORE', 'UTF-8') |
23 | - comment_text = ic.iconv("@#{parsed["user"]["name"]} " + _('said:') + " #{parsed["text"]}" + ' ')[0..-2] | 23 | + comment_text = ic.iconv("@#{parsed["user"]["name"]} " + _('said') + ": #{parsed["text"]}" + ' ')[0..-2] |
24 | print "#{comment_text}\n" | 24 | print "#{comment_text}\n" |
25 | comment = Comment.new | 25 | comment = Comment.new |
26 | comment.source_id = Stream.page.id | 26 | comment.source_id = Stream.page.id |