facebook_topics 1.1.0
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 +7 -0
- data/README.md +0 -0
- data/bin/console +1 -0
- data/lib/facebook_topics/api.rb +65 -0
- data/lib/facebook_topics/error.rb +12 -0
- data/lib/facebook_topics/results/collection.rb +14 -0
- data/lib/facebook_topics/results/feed.rb +17 -0
- data/lib/facebook_topics/results/feed_collection.rb +40 -0
- data/lib/facebook_topics/results/insight.rb +12 -0
- data/lib/facebook_topics/results/topic.rb +18 -0
- data/lib/facebook_topics/results/topic_collection.rb +10 -0
- data/lib/facebook_topics.rb +14 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6e71fb7111c50652c1ca4ca49b507d2418d731db
|
4
|
+
data.tar.gz: afb0e508953032f1b99932446d504bb555b89798
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: df1a0359c43122ba1a4be9fbd6cc6446eacbeb6fc21e642765497523c0672de0a75f31f860ccd3726c523143a7406e4ec4ba53d6503398956671aaac572e599c
|
7
|
+
data.tar.gz: d3bd3126b1b73e09fdcd8f318210ef1623ef52fabf5250618f1f788b77a3951061530d3cf9b789b7204a2780e7385baee068fb0fcd54f2371b94980dae007db8
|
data/README.md
ADDED
File without changes
|
data/bin/console
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
irb -r./config/boot.console
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module FacebookTopics
|
2
|
+
class Api
|
3
|
+
include ::HTTParty
|
4
|
+
|
5
|
+
base_uri "https://graph.facebook.com"
|
6
|
+
|
7
|
+
attr_accessor :auth_token, :api_version
|
8
|
+
|
9
|
+
def initialize(attrs)
|
10
|
+
@auth_token = attrs.delete(:auth_token)
|
11
|
+
@api_version = attrs.delete(:api_version)
|
12
|
+
|
13
|
+
self.class.default_params access_token: @auth_token
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
def search(query, fields = [])
|
21
|
+
q = {q: query, type: 'topic'}
|
22
|
+
q.merge!(fields: fields.join(',')) unless fields.empty?
|
23
|
+
|
24
|
+
TopicCollection.new self.class.get("/#{api_version}/search", {query: q})["data"]
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
def quick(topic, fields = [], options = {})
|
32
|
+
topic_id = search(topic, fields).first.id
|
33
|
+
feeds(topic_id, fields, options)
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
def feeds(topic_id, fields = [], options = {})
|
41
|
+
fields = ["ranked_posts"] + fields
|
42
|
+
q = {fields: fields.flatten.uniq.join(',')}
|
43
|
+
q.merge! options
|
44
|
+
|
45
|
+
FeedCollection.new self.class.get("/#{api_version}/#{topic_id}", {query: q}).parsed_response
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
def insights(contains_all, date_range = nil, fields = [])
|
52
|
+
q = {contains_all: [contains_all], fields: fields.flatten.uniq.join(',')}
|
53
|
+
Insights.new self.class.get("/#{api_version}/topic_insights", {query: q}).parsed_response
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
def api_version
|
61
|
+
@api_version || "v2.3"
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
|
3
|
+
module FacebookTopics
|
4
|
+
class Collection
|
5
|
+
extend Forwardable
|
6
|
+
|
7
|
+
def_delegators :@results, :<<, :length, :first, :last, :collect, :to_a, :each, :reject, :select, :count, :[], :empty?
|
8
|
+
|
9
|
+
def initialize(results = [])
|
10
|
+
raise ApiError.new(results["error"]) if results.has_key? "error"
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module FacebookTopics
|
2
|
+
class FeedCollection < Collection
|
3
|
+
attr_accessor :paging, :id
|
4
|
+
|
5
|
+
def initialize(results = [])
|
6
|
+
super(results)
|
7
|
+
|
8
|
+
@id = results["id"]
|
9
|
+
@paging = results["paging"] || results["ranked_posts"]["paging"]
|
10
|
+
@results = (results["data"] || results["ranked_posts"]["data"] || []).collect { |r| FacebookTopics::Feed.new r }
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
def next
|
17
|
+
next_url = URI.encode paging["next"]
|
18
|
+
FeedCollection.new HTTParty.get(URI.parse(next_url)).parsed_response
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
def previous
|
26
|
+
previous_url = URI.encode paging["previous"]
|
27
|
+
FeedCollection.new HTTParty.get(URI.parse(previous_url)).parsed_response
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
def id
|
35
|
+
@id
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module FacebookTopics
|
2
|
+
class Insights
|
3
|
+
attr_accessor :volume, :breakdown
|
4
|
+
|
5
|
+
def initialize(results = [])
|
6
|
+
@volume = results["data"].first["mentions"]["data"].shift["count"].to_i
|
7
|
+
@breakdown = results["data"].first["mentions"]["data"]
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rainbow/ext/string'
|
3
|
+
|
4
|
+
require 'facebook_topics/api'
|
5
|
+
require 'facebook_topics/error'
|
6
|
+
require 'facebook_topics/results/collection'
|
7
|
+
require 'facebook_topics/results/feed_collection'
|
8
|
+
require 'facebook_topics/results/topic_collection'
|
9
|
+
require 'facebook_topics/results/feed'
|
10
|
+
require 'facebook_topics/results/topic'
|
11
|
+
|
12
|
+
module FacebookTopics
|
13
|
+
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: facebook_topics
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Spencer Markowski
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rainbow
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: hashie
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.4'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: httparty
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.13'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.13'
|
55
|
+
description: Search Facebook topics and retrieve feeds related to those topics.
|
56
|
+
email:
|
57
|
+
- spencer@theablefew.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- README.md
|
63
|
+
- bin/console
|
64
|
+
- lib/facebook_topics.rb
|
65
|
+
- lib/facebook_topics/api.rb
|
66
|
+
- lib/facebook_topics/error.rb
|
67
|
+
- lib/facebook_topics/results/collection.rb
|
68
|
+
- lib/facebook_topics/results/feed.rb
|
69
|
+
- lib/facebook_topics/results/feed_collection.rb
|
70
|
+
- lib/facebook_topics/results/insight.rb
|
71
|
+
- lib/facebook_topics/results/topic.rb
|
72
|
+
- lib/facebook_topics/results/topic_collection.rb
|
73
|
+
homepage: http://github.com/theablefew/facebook_topics
|
74
|
+
licenses: []
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.3.6
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.4.3
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Wrapper for Facebook Topic APIs
|
96
|
+
test_files: []
|