Class: SecondHandler::FbSinglePost

Inherits:
Object
  • Object
show all
Includes:
FbDataHandler
Defined in:
lib/second_handler.rb

Constant Summary

Constants included from FbDataHandler

FbDataHandler::FACEBOOK_URL

Instance Method Summary collapse

Constructor Details

#initialize(access_token, post_id) ⇒ FbSinglePost



12
13
14
15
# File 'lib/second_handler.rb', line 12

def initialize (access_token, post_id)
  @graph = Koala::Facebook::API.new(access_token)
  @post_id = post_id
end

Instance Method Details

#first_commentObject



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/second_handler.rb', line 29

def first_comment
  @comment = @graph.get_connections(@post_id, "comments",
    :limit=>1,
    :fields => ["from{name,id,picture}",
      "id",
      "message",
      "created_time",
      "like_count", 
    ]
  )
end

#get_commentObject



63
64
65
66
67
# File 'lib/second_handler.rb', line 63

def get_comment
  @comment.map do |single_comment|
    clean_comment(single_comment)
  end
end

#get_post_basicObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/second_handler.rb', line 16

def get_post_basic
  @basic = @graph.get_object(@post_id, :fields =>[
    "attachments{media,subattachments{media}}",
    "id",
    "message",
    "updated_time",
    "from{id,name,picture}",
    "comments.summary(1)",
    "likes.summary(1)"
  ])
  clean_post_content(@basic)
end

#next_page_commentObject



79
80
81
# File 'lib/second_handler.rb', line 79

def next_page_comment
  @comment = @comment.next_page
end

#next_page_comment_paramsObject



69
70
71
# File 'lib/second_handler.rb', line 69

def next_page_comment_params
  @comment.next_page_params
end

#previous_page_commentObject



83
84
85
# File 'lib/second_handler.rb', line 83

def previous_page_comment
  @comment = @comment.previous_page
end

#previous_page_comment_paramsObject



73
74
75
# File 'lib/second_handler.rb', line 73

def previous_page_comment_params
  @comment.previous_page_params
end

#specified_comment(token, action) ⇒ Object

Get specified page comment

Parameters:

token

paging token

actions

canbe :before or :after



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/second_handler.rb', line 48

def specified_comment(token, action)
  @comment = @graph.get_connections(@post_id, "comments",
    :limit=>1,
    :fields => ["from{name,id,picture}",
      "id",
      "message",
      "created_time",
      "like_count", 
    ],
    action => token,
  )
end