Commit f24f3ae5804d749ccfd83463794af645825c9175
1 parent
3851bf5c
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
fixed facebook
Showing
3 changed files
with
20 additions
and
19 deletions
Show diff stats
plugins/community_hub/facebook_stream/lib_facebook_stream.rb
| ... | ... | @@ -7,11 +7,12 @@ require 'json' |
| 7 | 7 | #'CAAD8cd4tMVkBAO3sh2DrzwZCDfeQq9ZAvTz7Jz24ZC26KtMfBoljqaXhD2vBV1zpP0bjrpxXUBzJvKKcFzOm6rMG9Sok7iNVUaxt5iwr7dfMqCvHpMboKpqrqgeLrfCH5ITVTAdezA6ZBSr9iOJrqyCSOYfui0zTmbXJ3FqtshwNRrRy4NPH' |
| 8 | 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 | 13 | @graph = Koala::Facebook::API.new(token) |
| 12 | 14 | initialComments = [] |
| 13 | 15 | extractedComments = [] |
| 14 | - newComments = [] | |
| 15 | 16 | firstTime = true |
| 16 | 17 | while true |
| 17 | 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 | 25 | } |
| 25 | 26 | array.each{ |comments| |
| 26 | 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 | 31 | extractedComments = extractedComments.uniq |
| ... | ... | @@ -34,12 +35,12 @@ def facebook_comments(hub_id, author_id, page_id="participabr", pooling_time=5, |
| 34 | 35 | end |
| 35 | 36 | newComments = extractedComments - initialComments |
| 36 | 37 | newComments = newComments.uniq |
| 37 | - initialCommentsinitialComments += newComments | |
| 38 | + initialComments += newComments | |
| 38 | 39 | initialComments = initialComments.uniq |
| 39 | 40 | newComments.each{|comment| |
| 40 | 41 | puts comment |
| 41 | 42 | noosferoComment = Comment.new |
| 42 | - noosferoComment.source_id = hub_id | |
| 43 | + noosferoComment.source_id = hub.id | |
| 43 | 44 | noosferoComment.body = comment |
| 44 | 45 | noosferoComment.author_id = author_id |
| 45 | 46 | noosferoComment.save! | ... | ... |
plugins/community_hub/lib/community_hub_plugin/hub.rb
| ... | ... | @@ -33,24 +33,24 @@ class CommunityHubPlugin::Hub < Folder |
| 33 | 33 | true |
| 34 | 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 | 44 | end |
| 45 | 45 | |
| 46 | - def self.facebook_service(page, action) | |
| 46 | + def self.facebook_service(hub, action) | |
| 47 | 47 | author_id = 54 |
| 48 | 48 | page_id="mundoreagindo" |
| 49 | 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 | 54 | @@facebook_thread_started = true |
| 55 | 55 | end |
| 56 | 56 | end | ... | ... |
plugins/community_hub/tweeter_stream/lib/twurl/request_controller.rb
| ... | ... | @@ -20,7 +20,7 @@ module Twurl |
| 20 | 20 | begin |
| 21 | 21 | parsed = JSON.parse(chunk) |
| 22 | 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 | 24 | print "#{comment_text}\n" |
| 25 | 25 | comment = Comment.new |
| 26 | 26 | comment.source_id = Stream.page.id | ... | ... |