fbrails 0.1.8 → 0.1.9.pre1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,52 @@
1
+ # Capobvious
2
+
3
+ capobvious is a recipes, which i use every day
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'fbrails'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install fbrails
18
+
19
+ ## Usage
20
+
21
+
22
+ http://developers.facebook.com/docs/authentication/
23
+
24
+
25
+ ```ruby
26
+ auth = Fbrails::Auth.new(app_id,app_secret,app_url)
27
+
28
+ auth.redirect_url # get a redirect page to server-flow authorization
29
+ auth.redirect_url(:user_birthday,:read_stream) # with permissions list
30
+
31
+ token = auth.token(code) # getting token from code which send back from facebook
32
+ # => {:token => "TOKEN", :expires => "TIME_WHEN_EXPIRES"}
33
+
34
+ Fbrails::Auth.token_valid?(token) # return true of false
35
+
36
+ Fbrails::Auth.token_valid?(token,expire_time) # return true of false
37
+
38
+
39
+
40
+ graph = Fbrails::Graph.new(token)
41
+
42
+ graph.me # return hash with your info or false
43
+ ```
44
+
45
+
46
+ ## Contributing
47
+
48
+ 1. Fork it
49
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
50
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
51
+ 4. Push to the branch (`git push origin my-new-feature`)
52
+ 5. Create new Pull Request
@@ -33,12 +33,16 @@ end
33
33
  return result
34
34
  end
35
35
 
36
- rescue HTTPClient::BadResponseError
37
- raise TokenExpired, "Token expired"
36
+ #rescue HTTPClient::BadResponseError
37
+ # raise TokenExpired, "Token expired"
38
38
  end
39
39
 
40
- def self.put(url)
41
-
40
+ def self.put(url, data)
41
+ #url = URI.parse(url)
42
+ begin
43
+ response = RestClient.put url, data, {:content_type => :json}
44
+ end
45
+ object = JSON.parse(response)
42
46
  end
43
47
 
44
48
 
@@ -6,9 +6,9 @@ module Fbrails
6
6
  @secret = secret
7
7
  end
8
8
 
9
- def redirect_url
9
+ def redirect_url(*scope)
10
10
  if !@app_id.blank? && !@app_url.blank?
11
- "https://www.facebook.com/dialog/oauth?client_id=#{@app_id}&redirect_uri=#{@app_url}"
11
+ "https://www.facebook.com/dialog/oauth?client_id=#{@app_id}&redirect_uri=#{@app_url}#{'&scope='+scope.join(',') unless scope.blank?}"
12
12
  else
13
13
  ""
14
14
  end
@@ -8,6 +8,9 @@ module Fbrails
8
8
  @token = token
9
9
  end
10
10
 
11
+ def get(url, params = '')
12
+ Fbrails.get(URL+url+access_token+params)
13
+ end
11
14
 
12
15
  def friends(fields = false)
13
16
  result = []
@@ -17,9 +20,7 @@ module Fbrails
17
20
  params = ""
18
21
  end
19
22
 
20
- friends = Fbrails.get(URL+"me"+"/"+"friends"+access_token+params)
21
-
22
-
23
+ friends = get('me/friends', params)
23
24
 
24
25
  loop do
25
26
  if friends.has_key?("paging") && friends["paging"].has_key?("next")
@@ -1,3 +1,3 @@
1
1
  module Fbrails
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9.pre1"
3
3
  end
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fbrails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
5
- prerelease:
4
+ version: 0.1.9.pre1
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Dmitry Gruzd
@@ -11,19 +11,24 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2011-11-04 00:00:00.000000000Z
14
+ date: 2013-03-01 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: httpclient
18
- requirement: &8379540 !ruby/object:Gem::Requirement
19
- none: false
18
+ prerelease: false
19
+ requirement: !ruby/object:Gem::Requirement
20
20
  requirements:
21
21
  - - ~>
22
22
  - !ruby/object:Gem::Version
23
23
  version: 2.2.2
24
+ none: false
24
25
  type: :runtime
25
- prerelease: false
26
- version_requirements: *8379540
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: 2.2.2
31
+ none: false
27
32
  description: Small gem for auth & getting info from facebook
28
33
  email:
29
34
  - donotsendhere@gmail.com
@@ -33,16 +38,12 @@ extra_rdoc_files: []
33
38
  files:
34
39
  - .gitignore
35
40
  - Gemfile
36
- - Gemfile~
37
- - README
41
+ - README.md
38
42
  - Rakefile
39
43
  - fbrails.gemspec
40
- - fbrails.gemspec~
41
44
  - lib/fbrails.rb
42
- - lib/fbrails.rb~
43
45
  - lib/fbrails/auth.rb
44
46
  - lib/fbrails/graph.rb
45
- - lib/fbrails/parse.rb~
46
47
  - lib/fbrails/version.rb
47
48
  homepage: ''
48
49
  licenses: []
@@ -51,20 +52,20 @@ rdoc_options: []
51
52
  require_paths:
52
53
  - lib
53
54
  required_ruby_version: !ruby/object:Gem::Requirement
54
- none: false
55
55
  requirements:
56
56
  - - ! '>='
57
57
  - !ruby/object:Gem::Version
58
58
  version: '0'
59
- required_rubygems_version: !ruby/object:Gem::Requirement
60
59
  none: false
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
61
  requirements:
62
- - - ! '>='
62
+ - - ! '>'
63
63
  - !ruby/object:Gem::Version
64
- version: '0'
64
+ version: 1.3.1
65
+ none: false
65
66
  requirements: []
66
67
  rubyforge_project: fbrails
67
- rubygems_version: 1.8.10
68
+ rubygems_version: 1.8.24
68
69
  signing_key:
69
70
  specification_version: 3
70
71
  summary: Small gem for auth & getting info from facebook
data/Gemfile~ DELETED
@@ -1,7 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
-
4
- gem 'httpclient'
5
-
6
- # Specify your gem's dependencies in fbrails.gemspec
7
- gemspec
data/README DELETED
@@ -1,22 +0,0 @@
1
- ## Developing ##
2
-
3
- http://developers.facebook.com/docs/authentication/
4
-
5
-
6
- auth = Fbrails::Auth.new(app_id,app_secret,app_url)
7
-
8
-
9
- auth.redirect_url # get a redirect page to server-flow authorization
10
-
11
- token = auth.token(code) # getting token from code which send back from facebook
12
- # => {:token => "TOKEN", :expires => "TIME_WHEN_EXPIRES"}
13
-
14
- Fbrails::Auth.token_valid?(token) # return true of false
15
- OR
16
- Fbrails::Auth.token_valid?(token,expire_time) # return true of false
17
-
18
-
19
-
20
- graph = Fbrails::Graph.new(token)
21
-
22
- graph.me # return hash with your info or false
@@ -1,27 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "fbrails/version"
4
-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = "fbrails"
8
- s.version = Fbrails::VERSION
9
- s.authors = ["Dmitry Gruzd", "Vitaly Mineev", "Ivan Shamatov"]
10
- s.email = ["donotsendhere@gmail.com"]
11
- s.homepage = ""
12
- s.summary = %q{Small gem for auth & getting info from facebook}
13
- s.description = %q{Small gem for auth & getting info from facebook}
14
-
15
- s.rubyforge_project = "fbrails"
16
-
17
- s.files = `git ls-files`.split("\n")
18
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
- s.require_paths = ["lib"]
21
-
22
- # specify any dependencies here; for example:
23
- # s.add_development_dependency "rspec"
24
- # s.add_runtime_dependency "rest-client"
25
- s.add_dependency "httpclient", '~2.2.2'
26
- #s.add_development_dependency "httpclient"
27
- end
@@ -1,45 +0,0 @@
1
- require 'rubygems'
2
- require "fbrails/version"
3
- #require 'net/https'
4
- #require 'json'
5
- #require 'httpclient'
6
-
7
-
8
- module Fbrails
9
-
10
- class FailedToGet < StandardError
11
- end
12
- def self.get (url,raw = false)
13
- # uri = URI.parse(url)
14
- # http = Net::HTTP.new(uri.host,uri.port)
15
- # http.use_ssl = true if url =~ /^https/
16
- # http.verify_mode = OpenSSL::SSL::VERIFY_NONE if url =~ /^https/
17
- # request = Net::HTTP::Get.new(uri.request_uri)
18
- # resp = http.request(request).body
19
- resp = ::HTTPClient.new.get_content(url)
20
- if raw
21
- return resp
22
- end
23
- result = JSON.parse(resp)
24
- if result.has_key?("error")
25
- raise FailedToGet, "Failed to get, probably token expired"
26
- else
27
- return result
28
- end
29
- end
30
-
31
- def self.put(url)
32
-
33
- end
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
- require 'fbrails/auth'
42
-
43
- require 'fbrails/graph'
44
-
45
- end
@@ -1,34 +0,0 @@
1
- module Fbrails
2
-
3
-
4
-
5
- class FailedToGet < StandardError
6
- end
7
- class Parse
8
- def self.get (url,raw = false)
9
- # uri = URI.parse(url)
10
- # http = Net::HTTP.new(uri.host,uri.port)
11
- # http.use_ssl = true if url =~ /^https/
12
- # http.verify_mode = OpenSSL::SSL::VERIFY_NONE if url =~ /^https/
13
- # request = Net::HTTP::Get.new(uri.request_uri)
14
- # resp = http.request(request).body
15
- resp = HTTPClient.new.get_content(url)
16
- if raw
17
- return resp
18
- end
19
- result = JSON.parse(resp)
20
- if result.has_key?("error")
21
- raise FailedToGet, "Failed to get, probably token expired"
22
- else
23
- return result
24
- end
25
- end
26
-
27
- def self.put(url)
28
-
29
- end
30
-
31
-
32
-
33
- end
34
- end