fgraph 0.1.3 → 0.1.4

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.
data/History CHANGED
@@ -1,3 +1,14 @@
1
+ v0.1.4 - May 22, 2010
2
+ * Update rdoc, client_id should refer to Application ID instead of
3
+ API Key (as of OAuth v2)
4
+ * Remove :app_id option from FGraph::Client
5
+
6
+ v0.1.3 - May 21, 2010
7
+ * Update rdoc
8
+
9
+ v0.1.2 - May 20, 2010
10
+ * Update rdoc
11
+
1
12
  v0.1.1 - May 20, 2010
2
13
  * Update rdoc
3
14
 
data/README.rdoc CHANGED
@@ -98,11 +98,11 @@ OAuth Application Access Token, required to access application anlytics data:
98
98
 
99
99
  === Insights
100
100
 
101
- # https://graph.facebook.com/app_id/insights?access_token=...
102
- FGraph.insights('[app_id]', '[app_access_token]')
101
+ # https://graph.facebook.com/client_id/insights?access_token=...
102
+ FGraph.insights('[client_id]', '[app_access_token]')
103
103
 
104
- # https://graph.facebook.com/app_id/insights/application_api_call/day?access_token=...
105
- FGraph.insights('[app_id]', '[app_access_token]', :metric_path => 'application_api_call/day')
104
+ # https://graph.facebook.com/client_id/insights/application_api_call/day?access_token=...
105
+ FGraph.insights('[client_id]', '[app_access_token]', :metric_path => 'application_api_call/day')
106
106
 
107
107
  === FGraph::Client
108
108
 
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- :patch: 3
2
+ :patch: 4
3
3
  :major: 0
4
4
  :build:
5
5
  :minor: 1
data/lib/fgraph.rb CHANGED
@@ -88,7 +88,7 @@ module FGraph
88
88
  # user's behalf. Returns Oauth Authorization URL, redirect to this URL to allow user to authorize your
89
89
  # application from Facebook.
90
90
  #
91
- # <tt>client_id</tt> - Facebook API Key
91
+ # <tt>client_id</tt> - Application ID
92
92
  # <tt>redirect_uri</tt> - Needs to begin with your app's Connect URL. For instance, if your Connect URL
93
93
  # is http://www.example.com then your redirect URI could be http://www.example.com/oauth_redirect.
94
94
  # <tt>scope (optional)</tt> -
@@ -217,20 +217,20 @@ module FGraph
217
217
 
218
218
  # Download insights data for your application.
219
219
  #
220
- # # https://graph.facebook.com/app_id/insights?access_token=...
221
- # FGraph.insights('[app_id]', '[app_access_token]')
220
+ # # https://graph.facebook.com/[client_id]/insights?access_token=...
221
+ # FGraph.insights('[client_id]', '[app_access_token]')
222
222
  #
223
- # # https://graph.facebook.com/app_id/insights/application_api_call/day?access_token=...
224
- # FGraph.insights('[app_id]', '[app_access_token]', :metric_path => 'application_api_call/day')
223
+ # # https://graph.facebook.com/[client_id]/insights/application_api_call/day?access_token=...
224
+ # FGraph.insights('[client_id]', '[app_access_token]', :metric_path => 'application_api_call/day')
225
225
  #
226
226
  # ==== Options
227
227
  # * <tt>metric_path</tt> - e.g. application_api_calls/day
228
228
  # * <tt>since</tt> - since (a unix timestamp or any date accepted by strtotime, e.g. yesterday)
229
229
  # * <tt>until</tt> - until (a unix timestamp or any date accepted by strtotime, e.g. yesterday)
230
- def self.insights(app_id, app_access_token, options={})
230
+ def self.insights(client_id, app_access_token, options={})
231
231
  metric_path = options.delete(:metric_path)
232
232
 
233
- path = "/#{app_id}/insights"
233
+ path = "/#{client_id}/insights"
234
234
  path += "/#{metric_path}" if metric_path
235
235
 
236
236
  self.perform_get(path, {
data/lib/fgraph/client.rb CHANGED
@@ -11,9 +11,8 @@ module FGraph
11
11
  # when calling respective Facebook Graph API methods.
12
12
  #
13
13
  # ==== Options
14
- # * <tt>client_id</tt> - Application API key
14
+ # * <tt>client_id</tt> - Application ID
15
15
  # * <tt>client_secret</tt> - Application Secret
16
- # * <tt>app_id</tt> - Application ID
17
16
  # * <tt>access_token</tt> - Access token, required to publish to Facebook Graph or access
18
17
  # current user profile.
19
18
  # * <tt>app_access_token</tt> - Application access token, required to access Facebook insights.
@@ -89,7 +88,7 @@ module FGraph
89
88
  unless self.options[:app_access_token]
90
89
  self.options[:app_access_token] = self.oauth_app_access_token
91
90
  end
92
- FGraph.insights(self.options[:app_id], self.options[:app_access_token], options)
91
+ FGraph.insights(self.options[:client_id], self.options[:app_access_token], options)
93
92
  end
94
93
 
95
94
  def method_missing(name, *args, &block)
@@ -0,0 +1,14 @@
1
+ require 'fileutils'
2
+
3
+ namespace :fgraph do
4
+ desc "Create fgraph.yml configuration file in Rails config folder"
5
+ task :setup => :environment do
6
+ fgraph_config = File.join(RAILS_ROOT, "config", "fgraph.yml")
7
+ unless File.exist?(fgraph_config)
8
+
9
+ else
10
+ puts "#{RAILS_ROOT}/config/fgraph.yml already exists."
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,9 +1,8 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class ClientTest < Test::Unit::TestCase
4
- FACEBOOK_API_KEY = '878116c4a4b79f25e4beb97ab096cc92'
5
- FACEBOOK_APP_SECRET = '41f0e7ee8b6501dca1610de9926477c4'
6
4
  FACEBOOK_APP_ID = '112157085578818'
5
+ FACEBOOK_APP_SECRET = '41f0e7ee8b6501dca1610de9926477c4'
7
6
  FACEBOOK_OAUTH_REDIRECT_URI = 'http://www.example.com/oauth_redirect'
8
7
  FACEBOOK_OAUTH_CODE = '2.0eXhebBSDTpoe08qIaocNQ__.3600.1273748400-503153225|caqygNb5Gobz6lpj3HXjlthDxds.'
9
8
  FACEBOOK_OAUTH_ACCESS_TOKEN = "115187085478818|rDIv_5zgjCSM_fWBv5Z-lQr5gFk."
@@ -11,7 +10,7 @@ class ClientTest < Test::Unit::TestCase
11
10
 
12
11
  def fb_client
13
12
  FGraph::Client.new(
14
- :client_id => FACEBOOK_API_KEY,
13
+ :client_id => FACEBOOK_APP_ID,
15
14
  :client_secret => FACEBOOK_APP_SECRET,
16
15
  :access_token => FACEBOOK_OAUTH_ACCESS_TOKEN
17
16
  )
@@ -19,7 +18,7 @@ class ClientTest < Test::Unit::TestCase
19
18
 
20
19
  context "FGraph::Client#oauth_authorize_url" do
21
20
  should "call FGraph.oauth_authorize_url with :client_id option" do
22
- FGraph.expects(:oauth_authorize_url).with(FACEBOOK_API_KEY, FACEBOOK_OAUTH_REDIRECT_URI, {
21
+ FGraph.expects(:oauth_authorize_url).with(FACEBOOK_APP_ID, FACEBOOK_OAUTH_REDIRECT_URI, {
23
22
  :scope => 'publish_stream'
24
23
  })
25
24
  fb_client.oauth_authorize_url(FACEBOOK_OAUTH_REDIRECT_URI, :scope => 'publish_stream')
@@ -28,7 +27,7 @@ class ClientTest < Test::Unit::TestCase
28
27
 
29
28
  context "FGraph::Client#oauth_access_token" do
30
29
  should "call FGraph.oauth_access_token with :client_id and :client_secret options" do
31
- FGraph.expects(:oauth_access_token).with(FACEBOOK_API_KEY, FACEBOOK_APP_SECRET,
30
+ FGraph.expects(:oauth_access_token).with(FACEBOOK_APP_ID, FACEBOOK_APP_SECRET,
32
31
  :redirect_uri => FACEBOOK_OAUTH_REDIRECT_URI, :code => FACEBOOK_OAUTH_CODE)
33
32
 
34
33
  fb_client.oauth_access_token(FACEBOOK_OAUTH_REDIRECT_URI, FACEBOOK_OAUTH_CODE)
@@ -135,9 +134,8 @@ class ClientTest < Test::Unit::TestCase
135
134
  end
136
135
 
137
136
  context "FGraph::Client#insights" do
138
- should "auto populate :app_id and :oauth_app_access_token" do
137
+ should "auto populate :client_id and :oauth_app_access_token" do
139
138
  client = fb_client
140
- client.options[:app_id] = FACEBOOK_APP_ID
141
139
  client.options[:app_access_token] = FACEBOOK_OAUTH_APP_ACCESS_TOKEN
142
140
 
143
141
  FGraph.expects(:insights).with(FACEBOOK_APP_ID, FACEBOOK_OAUTH_APP_ACCESS_TOKEN, {})
@@ -146,9 +144,8 @@ class ClientTest < Test::Unit::TestCase
146
144
 
147
145
  should "auto retrieve :oauth_app_access_token option" do
148
146
  client = fb_client
149
-
150
147
  client.expects(:oauth_app_access_token).returns(FACEBOOK_OAUTH_APP_ACCESS_TOKEN)
151
- FGraph.expects(:insights).with(nil, FACEBOOK_OAUTH_APP_ACCESS_TOKEN, {
148
+ FGraph.expects(:insights).with(FACEBOOK_APP_ID, FACEBOOK_OAUTH_APP_ACCESS_TOKEN, {
152
149
  :metric_path => 'application_api_calls/day'
153
150
  })
154
151
  client.insights(:metric_path => 'application_api_calls/day')
data/test/fgraph_test.rb CHANGED
@@ -1,9 +1,8 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class FGraphTest < Test::Unit::TestCase
4
- FACEBOOK_API_KEY = '878116c4a4b79f25e4beb97ab096cc92'
5
- FACEBOOK_APP_SECRET = '41f0e7ee8b6501dca1610de9926477c4'
6
4
  FACEBOOK_APP_ID = '112157085578818'
5
+ FACEBOOK_APP_SECRET = '41f0e7ee8b6501dca1610de9926477c4'
7
6
  FACEBOOK_OAUTH_REDIRECT_URI = 'http://www.example.com/oauth_redirect'
8
7
  FACEBOOK_OAUTH_CODE = '2.0eXhebBSDTpoe08qIaocNQ__.3600.1273748400-503153225|caqygNb5Gobz6lpj3HXjlthDxds.'
9
8
  FACEBOOK_OAUTH_ACCESS_TOKEN = "115187085478818|rDIv_5zgjCSM_fWBv5Z-lQr5gFk."
@@ -56,21 +55,21 @@ class FGraphTest < Test::Unit::TestCase
56
55
  context "FGraph.oauth_authorize_url" do
57
56
  should "should call format_url with appropriate hash" do
58
57
  FGraph.expects(:format_url).with('/oauth/authorize', {
59
- :client_id => FACEBOOK_API_KEY,
58
+ :client_id => FACEBOOK_APP_ID,
60
59
  :redirect_uri => FACEBOOK_OAUTH_REDIRECT_URI
61
60
  })
62
61
 
63
- FGraph.oauth_authorize_url(FACEBOOK_API_KEY, FACEBOOK_OAUTH_REDIRECT_URI)
62
+ FGraph.oauth_authorize_url(FACEBOOK_APP_ID, FACEBOOK_OAUTH_REDIRECT_URI)
64
63
  end
65
64
 
66
65
  should "should call format_url with options" do
67
66
  FGraph.expects(:format_url).with('/oauth/authorize', {
68
- :client_id => FACEBOOK_API_KEY,
67
+ :client_id => FACEBOOK_APP_ID,
69
68
  :redirect_uri => FACEBOOK_OAUTH_REDIRECT_URI,
70
69
  :scope => 'publish_stream'
71
70
  })
72
71
 
73
- FGraph.oauth_authorize_url(FACEBOOK_API_KEY, FACEBOOK_OAUTH_REDIRECT_URI,
72
+ FGraph.oauth_authorize_url(FACEBOOK_APP_ID, FACEBOOK_OAUTH_REDIRECT_URI,
74
73
  :scope => 'publish_stream')
75
74
  end
76
75
  end
@@ -78,13 +77,13 @@ class FGraphTest < Test::Unit::TestCase
78
77
  context "FGraph.oauth_access_token" do
79
78
  should "return user access token and expires" do
80
79
  stub_get(FGraph.format_url('/oauth/access_token', {
81
- :client_id => FACEBOOK_API_KEY,
80
+ :client_id => FACEBOOK_APP_ID,
82
81
  :client_secret => FACEBOOK_APP_SECRET,
83
82
  :redirect_uri => FACEBOOK_OAUTH_REDIRECT_URI,
84
83
  :code => FACEBOOK_OAUTH_CODE
85
84
  }), 'access_token.txt')
86
85
 
87
- token = FGraph.oauth_access_token(FACEBOOK_API_KEY, FACEBOOK_APP_SECRET,
86
+ token = FGraph.oauth_access_token(FACEBOOK_APP_ID, FACEBOOK_APP_SECRET,
88
87
  :redirect_uri => FACEBOOK_OAUTH_REDIRECT_URI,
89
88
  :code => FACEBOOK_OAUTH_CODE)
90
89
 
@@ -141,7 +140,7 @@ class FGraphTest < Test::Unit::TestCase
141
140
  end
142
141
 
143
142
  context "Facebook.insights" do
144
- should "call perform_get('/[app_id]/insights')" do
143
+ should "call perform_get('/[client_id]/insights')" do
145
144
  FGraph.expects(:perform_get).with("/#{FACEBOOK_APP_ID}/insights", {
146
145
  :access_token => FACEBOOK_OAUTH_APP_ACCESS_TOKEN
147
146
  })
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 3
9
- version: 0.1.3
8
+ - 4
9
+ version: 0.1.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Herryanto Siatono
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-21 00:00:00 +08:00
17
+ date: 2010-05-22 00:00:00 +08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -105,6 +105,7 @@ files:
105
105
  - examples/publish_feed.rb
106
106
  - lib/fgraph.rb
107
107
  - lib/fgraph/client.rb
108
+ - lib/tasks/fgraph.rake
108
109
  - test/fgraph/client_test.rb
109
110
  - test/fgraph_test.rb
110
111
  - test/fixtures/access_token.txt