mini_fb 2.1.0 → 2.2.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 +4 -4
- data/.gitignore +1 -0
- data/Gemfile +4 -1
- data/Gemfile.lock +30 -16
- data/lib/mini_fb.rb +72 -16
- data/lib/version.rb +1 -1
- data/mini_fb.gemspec +4 -5
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be505723cf0db6d36400587903da97d34d916c95
|
4
|
+
data.tar.gz: dc822865779c05341d3316547d57d9fbb0f48370
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0e2e566abcaedf70de9c9b2b0c97c2dbbc6a05894174fc960ecfdd30dc06ab67f814942d107fb16dfff61562eabc7456fe18c4e086ee545efc16dd8c3b32b84
|
7
|
+
data.tar.gz: b32d26ce35a3ecb08744530a5739d0637ccc7192652c5126471f3367b285144e4cde24d11cd9eb45912052b594807589d738fd7b616090f671065b494c16ab85
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,30 +1,44 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mini_fb (2.
|
4
|
+
mini_fb (2.0.0)
|
5
5
|
hashie
|
6
|
-
|
6
|
+
hashie
|
7
|
+
rest-client
|
8
|
+
rest-client
|
7
9
|
|
8
10
|
GEM
|
9
11
|
remote: https://rubygems.org/
|
10
12
|
specs:
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
13
|
+
activesupport (3.2.12)
|
14
|
+
i18n (~> 0.6)
|
15
|
+
multi_json (~> 1.0)
|
16
|
+
diff-lcs (1.1.3)
|
17
|
+
git (1.2.5)
|
18
|
+
hashie (2.0.2)
|
19
|
+
i18n (0.6.4)
|
20
|
+
jeweler2 (2.0.9)
|
21
|
+
git (>= 1.2.5)
|
22
|
+
mime-types (1.21)
|
23
|
+
multi_json (1.6.1)
|
24
|
+
rake (10.0.3)
|
25
|
+
rest-client (1.6.7)
|
26
|
+
mime-types (>= 1.16)
|
27
|
+
rspec (2.11.0)
|
28
|
+
rspec-core (~> 2.11.0)
|
29
|
+
rspec-expectations (~> 2.11.0)
|
30
|
+
rspec-mocks (~> 2.11.0)
|
31
|
+
rspec-core (2.11.1)
|
32
|
+
rspec-expectations (2.11.3)
|
33
|
+
diff-lcs (~> 1.1.3)
|
34
|
+
rspec-mocks (2.11.2)
|
24
35
|
|
25
36
|
PLATFORMS
|
26
37
|
ruby
|
27
38
|
|
28
39
|
DEPENDENCIES
|
40
|
+
activesupport
|
41
|
+
jeweler2
|
29
42
|
mini_fb!
|
30
|
-
|
43
|
+
rake
|
44
|
+
rspec (~> 2.11.0)
|
data/lib/mini_fb.rb
CHANGED
@@ -14,12 +14,11 @@
|
|
14
14
|
require 'digest/md5'
|
15
15
|
require 'erb'
|
16
16
|
require 'json' unless defined? JSON
|
17
|
-
require '
|
17
|
+
require 'httpclient'
|
18
18
|
require 'hashie'
|
19
19
|
require 'base64'
|
20
20
|
require 'openssl'
|
21
21
|
require 'logger'
|
22
|
-
require_relative 'version'
|
23
22
|
|
24
23
|
module MiniFB
|
25
24
|
|
@@ -29,6 +28,8 @@ module MiniFB
|
|
29
28
|
|
30
29
|
@@logging = false
|
31
30
|
@@log = Logger.new(STDOUT)
|
31
|
+
@@http = HTTPClient.new
|
32
|
+
|
32
33
|
|
33
34
|
def self.log_level=(level)
|
34
35
|
if level.is_a? Numeric
|
@@ -318,7 +319,7 @@ module MiniFB
|
|
318
319
|
def self.verify_signed_request(secret, req)
|
319
320
|
s, p = req.split(".")
|
320
321
|
sig = base64_url_decode(s)
|
321
|
-
expected_sig = OpenSSL::HMAC.digest('SHA256', secret, p
|
322
|
+
expected_sig = OpenSSL::HMAC.digest('SHA256', secret, p)
|
322
323
|
return sig == expected_sig
|
323
324
|
end
|
324
325
|
|
@@ -508,7 +509,7 @@ module MiniFB
|
|
508
509
|
oauth_url << "&redirect_uri=#{CGI.escape(redirect_uri)}"
|
509
510
|
oauth_url << "&client_secret=#{secret}"
|
510
511
|
oauth_url << "&code=#{CGI.escape(code)}"
|
511
|
-
resp =
|
512
|
+
resp = @@http.get oauth_url
|
512
513
|
puts 'resp=' + resp.body.to_s if @@logging
|
513
514
|
params = {}
|
514
515
|
params_array = resp.split("&")
|
@@ -526,7 +527,7 @@ module MiniFB
|
|
526
527
|
oauth_url << "&client_secret=#{secret}"
|
527
528
|
oauth_url << "&grant_type=fb_exchange_token"
|
528
529
|
oauth_url << "&fb_exchange_token=#{CGI.escape(access_token)}"
|
529
|
-
resp =
|
530
|
+
resp = @@http.get oauth_url
|
530
531
|
puts 'resp=' + resp.body.to_s if @@logging
|
531
532
|
params = {}
|
532
533
|
params_array = resp.split("&")
|
@@ -557,13 +558,12 @@ module MiniFB
|
|
557
558
|
params["type"] = "client_cred"
|
558
559
|
params["client_id"] = "#{app_id}"
|
559
560
|
params["client_secret"] = "#{secret}"
|
560
|
-
# resp = RestClient.get url
|
561
561
|
options = {}
|
562
562
|
options[:params] = params
|
563
563
|
options[:method] = :get
|
564
564
|
options[:response_type] = :params
|
565
565
|
resp = fetch(url, options)
|
566
|
-
puts 'resp=' + resp if @@logging
|
566
|
+
puts 'resp=' + resp.to_s if @@logging
|
567
567
|
resp
|
568
568
|
end
|
569
569
|
|
@@ -583,6 +583,28 @@ module MiniFB
|
|
583
583
|
return fetch(url, options)
|
584
584
|
end
|
585
585
|
|
586
|
+
# Gets multiple data from the Facebook Graph API
|
587
|
+
# options:
|
588
|
+
# - type: eg: feed, home, etc
|
589
|
+
# - metadata: to include metadata in response. true/false
|
590
|
+
# - params: Any additional parameters you would like to submit
|
591
|
+
# Example:
|
592
|
+
#
|
593
|
+
# MiniFB.multiget(access_token, [123, 234])
|
594
|
+
#
|
595
|
+
# Can throw a connection Timeout if there is too many items
|
596
|
+
def self.multiget(access_token, ids, options={})
|
597
|
+
url = "#{graph_base}"
|
598
|
+
url << "#{options[:type]}" if options[:type]
|
599
|
+
params = options[:params] || {}
|
600
|
+
params["ids"] = ids.join(',')
|
601
|
+
params["access_token"] = "#{(access_token)}"
|
602
|
+
params["metadata"] = "1" if options[:metadata]
|
603
|
+
params["fields"] = options[:fields].join(",") if options[:fields]
|
604
|
+
options[:params] = params
|
605
|
+
return fetch(url, options)
|
606
|
+
end
|
607
|
+
|
586
608
|
# Posts data to the Facebook Graph API
|
587
609
|
# options:
|
588
610
|
# - type: eg: feed, home, etc
|
@@ -608,6 +630,31 @@ module MiniFB
|
|
608
630
|
|
609
631
|
end
|
610
632
|
|
633
|
+
# Sends a DELETE request to the Facebook Graph API
|
634
|
+
# options:
|
635
|
+
# - type: eg: feed, home, etc
|
636
|
+
# - metadata: to include metadata in response. true/false
|
637
|
+
# - params: Any additional parameters you would like to submit
|
638
|
+
def self.delete(access_token, ids, options={})
|
639
|
+
url = "#{graph_base}"
|
640
|
+
params = options[:params] || {}
|
641
|
+
if ids.is_a?(Array)
|
642
|
+
params["ids"] = ids.join(',')
|
643
|
+
else
|
644
|
+
url << "#{ids}"
|
645
|
+
end
|
646
|
+
url << "/#{options[:type]}" if options[:type]
|
647
|
+
options.delete(:type)
|
648
|
+
options.each do |key, value|
|
649
|
+
params[key] = "#{value}"
|
650
|
+
end
|
651
|
+
params["access_token"] = "#{(access_token)}"
|
652
|
+
options[:params] = params
|
653
|
+
options[:method] = :delete
|
654
|
+
return fetch(url, options)
|
655
|
+
|
656
|
+
end
|
657
|
+
|
611
658
|
# Executes an FQL query
|
612
659
|
def self.fql(access_token, fql_query, options={})
|
613
660
|
url = "https://api.facebook.com/method/fql.query"
|
@@ -651,18 +698,27 @@ module MiniFB
|
|
651
698
|
def self.fetch(url, options={})
|
652
699
|
|
653
700
|
begin
|
654
|
-
|
701
|
+
case options[:method]
|
702
|
+
when :post
|
655
703
|
@@log.debug 'url_post=' + url if @@logging
|
656
|
-
|
704
|
+
response = @@http.post url, options[:params]
|
705
|
+
when :delete
|
706
|
+
if options[:params] && options[:params].size > 0
|
707
|
+
url += '?' + options[:params].map { |k, v| CGI.escape(k.to_s) + '=' + CGI.escape(v.to_s) }.join('&')
|
708
|
+
end
|
709
|
+
@@log.debug 'url_delete=' + url if @@logging
|
710
|
+
response = @@http.delete url
|
657
711
|
else
|
658
712
|
if options[:params] && options[:params].size > 0
|
659
713
|
url += '?' + options[:params].map { |k, v| CGI.escape(k.to_s) + '=' + CGI.escape(v.to_s) }.join('&')
|
660
714
|
end
|
661
715
|
@@log.debug 'url_get=' + url if @@logging
|
662
|
-
|
716
|
+
response = @@http.get url
|
663
717
|
end
|
664
718
|
|
665
|
-
|
719
|
+
resp = response.body
|
720
|
+
@@log.debug 'Response = ' + resp if @@logging
|
721
|
+
@@log.debug 'API Version =' + resp.headers["Facebook-API-Version"].to_s if @@logging
|
666
722
|
|
667
723
|
if options[:response_type] == :params
|
668
724
|
# Some methods return a param like string, for example: access_token=11935261234123|rW9JMxbN65v_pFWQl5LmHHABC
|
@@ -694,11 +750,11 @@ module MiniFB
|
|
694
750
|
end
|
695
751
|
|
696
752
|
return res_hash
|
697
|
-
rescue
|
698
|
-
puts "ex.http_code=" +
|
699
|
-
puts 'ex.http_body=' +
|
700
|
-
res_hash = JSON.parse(
|
701
|
-
raise MiniFB::FaceBookError.new(
|
753
|
+
rescue Exception => ex
|
754
|
+
puts "ex.http_code=" + response.status if @@logging
|
755
|
+
puts 'ex.http_body=' + resp if @@logging
|
756
|
+
res_hash = JSON.parse(resp) # probably should ensure it has a good response
|
757
|
+
raise MiniFB::FaceBookError.new(response.status, "#{res_hash["error"]["type"]}: #{res_hash["error"]["message"]}")
|
702
758
|
end
|
703
759
|
|
704
760
|
end
|
data/lib/version.rb
CHANGED
data/mini_fb.gemspec
CHANGED
@@ -3,8 +3,8 @@ require File.expand_path('../lib/version', __FILE__)
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
4
|
gem.authors = ["Travis Reeder"]
|
5
5
|
gem.email = ["travis@appoxy.com"]
|
6
|
-
gem.description = "Tiny facebook library
|
7
|
-
gem.summary = "Tiny facebook library
|
6
|
+
gem.description = "Tiny facebook library. By http://www.appoxy.com"
|
7
|
+
gem.summary = "Tiny facebook library. By http://www.appoxy.com"
|
8
8
|
gem.homepage = "http://github.com/appoxy/mini_fb/"
|
9
9
|
|
10
10
|
gem.files = `git ls-files`.split($\)
|
@@ -15,8 +15,7 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.version = MiniFB::VERSION
|
16
16
|
|
17
17
|
gem.required_rubygems_version = ">= 1.3.6"
|
18
|
-
gem.required_ruby_version = Gem::Requirement.new(">= 1.
|
19
|
-
gem.add_runtime_dependency "
|
18
|
+
gem.required_ruby_version = Gem::Requirement.new(">= 1.8")
|
19
|
+
gem.add_runtime_dependency "httpclient", ">= 0"
|
20
20
|
gem.add_runtime_dependency "hashie", ">= 0"
|
21
|
-
|
22
21
|
end
|
metadata
CHANGED
@@ -1,52 +1,52 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mini_fb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Travis Reeder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: httpclient
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: hashie
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
description: Tiny facebook library
|
41
|
+
description: Tiny facebook library. By http://www.appoxy.com
|
42
42
|
email:
|
43
43
|
- travis@appoxy.com
|
44
44
|
executables: []
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
-
- .gitignore
|
49
|
-
- .rvmrc
|
48
|
+
- ".gitignore"
|
49
|
+
- ".rvmrc"
|
50
50
|
- Gemfile
|
51
51
|
- Gemfile.lock
|
52
52
|
- LICENSE.txt
|
@@ -65,19 +65,19 @@ require_paths:
|
|
65
65
|
- lib
|
66
66
|
required_ruby_version: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
|
-
- -
|
68
|
+
- - ">="
|
69
69
|
- !ruby/object:Gem::Version
|
70
|
-
version: '1.
|
70
|
+
version: '1.8'
|
71
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: 1.3.6
|
76
76
|
requirements: []
|
77
77
|
rubyforge_project:
|
78
|
-
rubygems_version: 2.
|
78
|
+
rubygems_version: 2.4.8
|
79
79
|
signing_key:
|
80
80
|
specification_version: 4
|
81
|
-
summary: Tiny facebook library
|
81
|
+
summary: Tiny facebook library. By http://www.appoxy.com
|
82
82
|
test_files:
|
83
83
|
- spec/mini_fb_spec.rb
|