rb_facebook 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/rb_facebook.rb +21 -18
  2. metadata +5 -7
data/lib/rb_facebook.rb CHANGED
@@ -1,14 +1,14 @@
1
1
  module RbFacebook
2
2
 
3
- VERSION = '0.0.5'
3
+ VERSION = '0.0.6'
4
4
  class Api
5
5
 
6
- attr_accessor :access_token, :app_id, :app_secret
6
+ attr_accessor :access_token, :app_id, :app_secret, :rest_api_host, :graph_api_host
7
7
 
8
8
  STATS_METRICS = ["impressions", "clicks", "spent", "social_impressions", "social_clicks", "social_spent", "actions", "unique_impressions", "social_unique_impressions", "unique_clicks", "social_unique_clicks", "connections"]
9
9
 
10
10
  def logged_in_user
11
- graph_api_parse('me')
11
+ graph_api_parse('me', :log_call_url => true)
12
12
  end
13
13
 
14
14
  def ads_accounts
@@ -133,7 +133,7 @@ module RbFacebook
133
133
  rest_api_parse('ads.getAdGroups', :params => params, :log_call_url => true)
134
134
  end
135
135
 
136
- def initialize
136
+ def initialize(args = {})
137
137
  load_tokens
138
138
  end
139
139
 
@@ -141,6 +141,9 @@ module RbFacebook
141
141
  tokens = YAML.load(File.open(File.join(Rails.root, 'config', 'facebook.yml')))
142
142
  self.app_secret = tokens[:APP_SECRET]
143
143
  self.app_id = tokens[:APP_ID]
144
+ self.rest_api_host = tokens[:REST_API_HOST] || 'api.facebook.com'
145
+ self.graph_api_host = tokens[:GRAPH_API_HOST] || 'graph.facebook.com'
146
+
144
147
  end
145
148
 
146
149
  def login_url(current_url, permissions=[:read_insights,:ads_management,:offline_access])
@@ -190,7 +193,7 @@ module RbFacebook
190
193
  use_access_token = !args[:no_access_token]
191
194
  log_call_url = args[:log_call_url]
192
195
 
193
- api_fetch('graph.facebook.com', method_name, api_params, use_access_token, log_call_url)
196
+ api_fetch(self.graph_api_host, method_name, api_params, use_access_token, log_call_url)
194
197
  end
195
198
 
196
199
  def rest_api_parse(method_name, args = {})
@@ -228,7 +231,7 @@ module RbFacebook
228
231
 
229
232
  api_params["format"] = 'json-strings'
230
233
 
231
- api_fetch('api.facebook.com/method', method_name, api_params, use_access_token, log_call_url, :mp_post => multipart_post)
234
+ api_fetch("#{self.rest_api_host}/method", method_name, api_params, use_access_token, log_call_url, :mp_post => multipart_post)
232
235
 
233
236
  end
234
237
 
@@ -244,10 +247,10 @@ module RbFacebook
244
247
  Rails.logger.warn("About to fetch: #{call_url}") if log_call_url
245
248
  Rails.logger.warn("Parameters: #{api_params.inspect}") if log_call_url
246
249
 
247
- tries = 0
248
- while tries < 5
249
- tries += 1
250
- begin
250
+ #tries = 0
251
+ #while tries < 5
252
+ #tries += 1
253
+ #begin
251
254
  uri = URI.parse(call_url)
252
255
  http = Net::HTTP.new(uri.host, uri.port)
253
256
  http.use_ssl = true
@@ -262,14 +265,14 @@ module RbFacebook
262
265
  else
263
266
  response = http.request(Net::HTTP::Get.new(uri.request_uri))
264
267
  end
265
- rescue Error => ex
266
- if tries > 5
267
- raise
268
- end
269
- else
270
- tries = 5
271
- end
272
- end
268
+ #rescue Exception => ex
269
+ # if tries > 5
270
+ # raise
271
+ # end
272
+ #else
273
+ # tries = 5
274
+ #end
275
+ #end
273
276
 
274
277
  Rails.logger.warn("And returned #{response.inspect}: #{response.body}") if log_call_url
275
278
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rb_facebook
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Joshua Levinson
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-02 00:00:00 +00:00
19
- default_executable:
18
+ date: 2011-10-28 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: rails
@@ -49,7 +48,6 @@ extra_rdoc_files: []
49
48
 
50
49
  files:
51
50
  - lib/rb_facebook.rb
52
- has_rdoc: true
53
51
  homepage: http://www.raybeam.com
54
52
  licenses: []
55
53
 
@@ -79,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
77
  requirements: []
80
78
 
81
79
  rubyforge_project: rb_facebook
82
- rubygems_version: 1.6.2
80
+ rubygems_version: 1.8.10
83
81
  signing_key:
84
82
  specification_version: 3
85
83
  summary: Lightweight wrapper around the facebook REST and Graph API