facebook_graphr 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{facebook_graphr}
8
- s.version = "0.1.4"
8
+ s.version = "0.1.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kevin Ball"]
@@ -1,5 +1,6 @@
1
+ require 'json'
1
2
  module FacebookGraphr
2
- BASE_URL = "https://graph.facebook.com/"
3
+ BASE_URL = "https://graph.facebook.com"
3
4
 
4
5
  class << self
5
6
  attr_writer :config
@@ -27,6 +28,8 @@ module FacebookGraphr
27
28
 
28
29
  def self.new_from_cookie(cookie)
29
30
  ::Rails.logger.info(cookie.inspect)
31
+ # Sometimes cookie comes in with extra quotes in front and back
32
+ cookie = cookie.chomp('"').reverse.chomp('"').reverse
30
33
  cookie_hash = cookie.split("&").inject({}) do |hash, pair|
31
34
  k, v = pair.split('=')
32
35
  hash.merge(k.to_sym => v)
@@ -44,15 +47,26 @@ module FacebookGraphr
44
47
 
45
48
  def api(path, params = {}, method = :get)
46
49
  params = params.reverse_merge(:access_token => self.access_token)
47
- res = if method == :get
50
+ code, body = if method == :get
48
51
  param_string = params.map {|k, v| "#{k}=#{v}"}.join("&")
49
- HTTParty.get(URI.escape(BASE_URL + path + "?" + param_string))
52
+ api_get(URI.escape(BASE_URL + path + "?" + param_string))
50
53
  else
51
- HTTParty.post(URI.escape(BASE_URL + path), options)
54
+ api_post(URI.escape(BASE_URL + path), options)
52
55
  end
53
- if res.code == 200
54
- JSON.parse(res.body)
56
+ if code == 200
57
+ JSON.parse(body)
55
58
  end
56
59
  end
60
+
61
+ #Set these up to be pluggable/overridable (e.g. so you can override them in app engine)
62
+ def api_get(uri)
63
+ res = HTTParty.get(uri)
64
+ [res.code, res.body]
65
+ end
66
+
67
+ def api_post(uri, options)
68
+ res = HTTParty.post(uri, options)
69
+ [res.code, res.body]
70
+ end
57
71
  end
58
72
  end
@@ -28,7 +28,7 @@ module FacebookGraphr
28
28
  # :linked => true/false
29
29
  def facebook_profile_pic(fbuid, options = {})
30
30
  options = options.dup
31
- content_tag("fb:profile-pick", nil, options.merge(:uid => fbuid))
31
+ content_tag("fb:profile-pic", nil, options.merge(:uid => fbuid))
32
32
  end
33
33
  end
34
34
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facebook_graphr
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 4
10
- version: 0.1.4
9
+ - 5
10
+ version: 0.1.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kevin Ball