secondHandler 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/fb_data_handler.rb +4 -0
- data/lib/second_handler.rb +44 -8
- data/lib/second_handler/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5c3ea70e13d227527ae314afb16ce1a69aebf7e
|
4
|
+
data.tar.gz: 9e82d8d82a76391db929ec56d6dc4a56cfaa9e59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0daf3cd83204b89e421645f929c6a3873886d9e2b7b2de5841e7b17da3ce5004b8e7e0a45b21ee78022edb4c8ad4c351e3ceb8f2048b0b87f99a6f647cc07547
|
7
|
+
data.tar.gz: 0ce6b4d1ad7342ac7941ed8a59b3f31233323b915e8b41a0288ebd9de58b98f7fc4ed628e8bccd938738a92b4d630740b965da15106d1388a92824c23cdeaf13
|
data/README.md
CHANGED
@@ -86,10 +86,10 @@ fbp.previous_page_comment #fetch previous page comments
|
|
86
86
|
|
87
87
|
CHANGELOG
|
88
88
|
===
|
89
|
-
2016-1-5 bump to v1.
|
89
|
+
2016-1-5 bump to v1.1.0
|
90
90
|
- add single post comment func
|
91
91
|
- modify `SecondHandler::FbGroupPost.get_content` output (no backward support!!!)
|
92
|
-
|
92
|
+
- add specified_page function to SecondHandler::FbGroupPost
|
93
93
|
|
94
94
|
## License
|
95
95
|
|
data/lib/fb_data_handler.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
module FbDataHandler
|
2
|
+
FACEBOOK_URL = "https://www.facebook.com/"
|
2
3
|
private
|
3
4
|
def attachment_helper (attach_hash, &func)
|
4
5
|
|
@@ -20,6 +21,7 @@ module FbDataHandler
|
|
20
21
|
def clean_post_content (item)
|
21
22
|
{
|
22
23
|
"id" => item["id"],
|
24
|
+
"origin_url" => FACEBOOK_URL+"/"+item["id"],
|
23
25
|
"message" => item["message"],
|
24
26
|
"updated_time" => item["updated_time"],
|
25
27
|
"attachments" => attachment_helper(item["attachments"]),
|
@@ -28,6 +30,8 @@ module FbDataHandler
|
|
28
30
|
"name" => item["from"]["name"],
|
29
31
|
"picture" => item["from"]["picture"]["data"],
|
30
32
|
},
|
33
|
+
"like_count"=> item["likes"]["summary"]["total_count"],
|
34
|
+
"comment_count"=> item["comments"]["summary"]["total_count"],
|
31
35
|
|
32
36
|
}
|
33
37
|
end
|
data/lib/second_handler.rb
CHANGED
@@ -5,7 +5,6 @@ require_relative 'fb_data_handler'
|
|
5
5
|
module SecondHandler
|
6
6
|
|
7
7
|
class FbSinglePost
|
8
|
-
FB_POSTS_FIELDS = ["attachments{media,subattachments{media}}","id","message","updated_time","from{id,name,picture}", ]
|
9
8
|
include FbDataHandler
|
10
9
|
|
11
10
|
|
@@ -14,13 +13,28 @@ module SecondHandler
|
|
14
13
|
@post_id = post_id
|
15
14
|
end
|
16
15
|
def get_post_basic
|
17
|
-
@basic = @graph.get_object(@post_id, :fields =>
|
16
|
+
@basic = @graph.get_object(@post_id, :fields =>[
|
17
|
+
"attachments{media,subattachments{media}}",
|
18
|
+
"id",
|
19
|
+
"message",
|
20
|
+
"updated_time",
|
21
|
+
"from{id,name,picture}",
|
22
|
+
"comments.summary(1)",
|
23
|
+
"likes.summary(1)"
|
24
|
+
])
|
18
25
|
clean_post_content(@basic)
|
19
26
|
end
|
20
27
|
|
21
28
|
def first_comment
|
22
|
-
@comment = @graph.get_connections(@post_id, "comments",
|
23
|
-
:
|
29
|
+
@comment = @graph.get_connections(@post_id, "comments",
|
30
|
+
:limit=>1,
|
31
|
+
:fields => ["from{name,id,picture}",
|
32
|
+
"id",
|
33
|
+
"message",
|
34
|
+
"created_time",
|
35
|
+
"like_count",
|
36
|
+
]
|
37
|
+
)
|
24
38
|
end
|
25
39
|
|
26
40
|
def get_comment
|
@@ -28,6 +42,17 @@ module SecondHandler
|
|
28
42
|
clean_comment(single_comment)
|
29
43
|
end
|
30
44
|
end
|
45
|
+
|
46
|
+
def next_page_comment_params
|
47
|
+
@comment.next_page_params
|
48
|
+
end
|
49
|
+
|
50
|
+
def previous_page_comment_params
|
51
|
+
@comment.previous_page_params
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
|
31
56
|
def next_page_comment
|
32
57
|
@comment = @comment.next_page
|
33
58
|
end
|
@@ -41,7 +66,15 @@ module SecondHandler
|
|
41
66
|
class FbGroupPost
|
42
67
|
include FbDataHandler
|
43
68
|
|
44
|
-
FB_POSTS_FIELDS = [
|
69
|
+
FB_POSTS_FIELDS = [
|
70
|
+
"attachments{media,subattachments{media}}",
|
71
|
+
"id",
|
72
|
+
"message",
|
73
|
+
"updated_time",
|
74
|
+
"from{id,name,picture}",
|
75
|
+
"comments.summary(1)",
|
76
|
+
"likes.summary(1)"
|
77
|
+
]
|
45
78
|
|
46
79
|
def initialize (access_token, group_id)
|
47
80
|
@graph = Koala::Facebook::API.new(access_token)
|
@@ -52,11 +85,14 @@ module SecondHandler
|
|
52
85
|
@feed = @graph.get_connections(@group_id, "feed",:fields => FB_POSTS_FIELDS )
|
53
86
|
end
|
54
87
|
|
55
|
-
def specified_page (page_token,until_stamp)
|
88
|
+
def specified_page (page_token,until_stamp=nil,since_stamp=nil)
|
89
|
+
|
56
90
|
@feed = @graph.get_connections(@group_id, "feed",
|
57
91
|
:__paging_token => page_token,
|
58
92
|
:until => until_stamp,
|
59
|
-
:
|
93
|
+
:since => since_stamp,
|
94
|
+
:fields => FB_POSTS_FIELDS
|
95
|
+
)
|
60
96
|
|
61
97
|
end
|
62
98
|
def next_page
|
@@ -77,7 +113,7 @@ module SecondHandler
|
|
77
113
|
|
78
114
|
# return feed of current page infomation , including image
|
79
115
|
def get_content (&func)
|
80
|
-
@feed.map do |single_post|
|
116
|
+
@feed.to_a.map do |single_post|
|
81
117
|
clean_post_content(single_post)
|
82
118
|
end
|
83
119
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: secondHandler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sheng Jung Wu
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2016-01-
|
14
|
+
date: 2016-01-06 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: minitest
|