gplus 0.1.0 → 0.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.
- data/README.md +88 -3
- data/gplus.gemspec +2 -2
- data/lib/gplus/activity.rb +11 -0
- data/lib/gplus/client.rb +1 -0
- data/lib/gplus/version.rb +1 -1
- metadata +9 -7
data/README.md
CHANGED
@@ -12,7 +12,7 @@ Lets work together to get Ruby on Google+ ASAP!
|
|
12
12
|
|
13
13
|
gem install gplus
|
14
14
|
|
15
|
-
##
|
15
|
+
## Creating and configuring your application
|
16
16
|
|
17
17
|
To make requests, you need to [create an application](https://code.google.com/apis/console) with access to the Google+ API.
|
18
18
|
|
@@ -22,6 +22,91 @@ You can then specify additional redirect URIs and allowed javascript origins.
|
|
22
22
|
|
23
23
|
You'll need the Client ID and Client secret that are generated. Keep them secure!
|
24
24
|
|
25
|
-
|
25
|
+
## Authorized requests
|
26
26
|
|
27
|
-
|
27
|
+
Create an instance of the client using the credentials from when you set up your application:
|
28
|
+
|
29
|
+
@client = Gplus::Client.new(
|
30
|
+
:client_id => 'YOUR_CLIENT_ID',
|
31
|
+
:client_secret => 'YOUR_CLIENT_SECRET',
|
32
|
+
:redirect_uri => 'http://example.com/oauth2callback'
|
33
|
+
)
|
34
|
+
|
35
|
+
Generate an authorization URL, and use it in a view:
|
36
|
+
|
37
|
+
@auth_url = @client.authorization_url
|
38
|
+
=> https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=YOUR_CLIENT_ID&redirect_uri= ...
|
39
|
+
|
40
|
+
= link_to 'Authorize This App', @auth_url
|
41
|
+
|
42
|
+
After the user authorizes your app, they will be redirected to your `redirect_uri`. Store `params[:code]`:
|
43
|
+
|
44
|
+
def oauth_callback_handler
|
45
|
+
current_user.update_attributes(:oauth_code => params[:code])
|
46
|
+
end
|
47
|
+
|
48
|
+
Finally, create an authorized client instance:
|
49
|
+
|
50
|
+
client.authorize(current_user.oauth_code)
|
51
|
+
|
52
|
+
## [People](http://developers.google.com/+/api/latest/people)
|
53
|
+
|
54
|
+
Get a person's profile with `client.get_person`:
|
55
|
+
|
56
|
+
person = client.get_person(id)
|
57
|
+
|
58
|
+
You can use the id 'me' in place of a Person ID to fetch information about the user the client is authorized as.
|
59
|
+
|
60
|
+
The person's profile will be returned as a nested hash:
|
61
|
+
|
62
|
+
person[:displayName]
|
63
|
+
person[:urls].count
|
64
|
+
person[:name][:middleName]
|
65
|
+
|
66
|
+
See the API documentation for [People](http://developers.google.com/+/api/latest/people) and [People: get](http://developers.google.com/+/api/latest/people/get) for more info.
|
67
|
+
|
68
|
+
## [Activities](http://developers.google.com/+/api/latest/activities)
|
69
|
+
|
70
|
+
Get an activity with `client.get_activity`:
|
71
|
+
|
72
|
+
activity = client.get_activity(id)
|
73
|
+
|
74
|
+
The activity will be returned as a nested hash:
|
75
|
+
|
76
|
+
activity[:actor][:displayName]
|
77
|
+
activity[:object][:replies][:totalItems]
|
78
|
+
activity[:attachments].each do { |a| a[:url] }
|
79
|
+
|
80
|
+
List a person's activities with `client.list_activities`:
|
81
|
+
|
82
|
+
activities = client.list_activities(id)
|
83
|
+
|
84
|
+
The list will be returned as a nested hash. The actual activities are in the `:items` array:
|
85
|
+
|
86
|
+
activities[:title]
|
87
|
+
activities[:updated]
|
88
|
+
activities[:items].each { |a| a.title }
|
89
|
+
|
90
|
+
By default, this will fetch 20 activities. You can fetch between 1 and 100 by passing a `:results` argument:
|
91
|
+
|
92
|
+
# Get 80 results
|
93
|
+
client.list_activities(id, :results => 80)
|
94
|
+
|
95
|
+
If you want more than 100 results, take the `:nextPageToken` returned from your first request, and pass it as a `:page` argument:
|
96
|
+
|
97
|
+
activities = client.list_activities(id, :results => 100)
|
98
|
+
more_activities = client.list_activities(id, :results => 100, :page => activities[:nextPageToken])
|
99
|
+
|
100
|
+
See the API documentation for [Activities](http://developers.google.com/+/api/latest/activities), [Activities: get](http://developers.google.com/+/api/latest/activities/get) and [Activities: list](http://developers.google.com/+/api/latest/activities/list).
|
101
|
+
|
102
|
+
## Contributing to Gplus
|
103
|
+
|
104
|
+
Please submit bug reports as [Github Issues](https://github.com/nfm/Gplus/issues).
|
105
|
+
|
106
|
+
For bonus points, submit a pull request:
|
107
|
+
|
108
|
+
1. Fork the project.
|
109
|
+
2. Create a topic branch.
|
110
|
+
3. Implement your feature or bug fix.
|
111
|
+
4. Commit and push your changes.
|
112
|
+
5. Submit a pull request. Please do not include changes to the gemspec or version.
|
data/gplus.gemspec
CHANGED
@@ -4,8 +4,8 @@ require File.expand_path('../lib/gplus/version', __FILE__)
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = ["Nicholas Firth-McCoy"]
|
6
6
|
gem.email = ["nicholas@2suggestions.com.au"]
|
7
|
-
gem.description = %q{
|
8
|
-
gem.summary = %q{}
|
7
|
+
gem.description = %q{A complete implementation of the Google plus API for Ruby}
|
8
|
+
gem.summary = %q{Google+ API implementation with support for authorized requests, People, and Activities}
|
9
9
|
gem.homepage = "https://github.com/nfm/gplus"
|
10
10
|
|
11
11
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
data/lib/gplus/client.rb
CHANGED
data/lib/gplus/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gplus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-09-16 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|
16
|
-
requirement: &
|
16
|
+
requirement: &17028120 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '1.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *17028120
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: oauth2
|
27
|
-
requirement: &
|
27
|
+
requirement: &17027640 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,8 +32,8 @@ dependencies:
|
|
32
32
|
version: '0.5'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
36
|
-
description:
|
35
|
+
version_requirements: *17027640
|
36
|
+
description: A complete implementation of the Google plus API for Ruby
|
37
37
|
email:
|
38
38
|
- nicholas@2suggestions.com.au
|
39
39
|
executables: []
|
@@ -46,6 +46,7 @@ files:
|
|
46
46
|
- Rakefile
|
47
47
|
- gplus.gemspec
|
48
48
|
- lib/gplus.rb
|
49
|
+
- lib/gplus/activity.rb
|
49
50
|
- lib/gplus/client.rb
|
50
51
|
- lib/gplus/person.rb
|
51
52
|
- lib/gplus/version.rb
|
@@ -72,5 +73,6 @@ rubyforge_project:
|
|
72
73
|
rubygems_version: 1.8.10
|
73
74
|
signing_key:
|
74
75
|
specification_version: 3
|
75
|
-
summary:
|
76
|
+
summary: Google+ API implementation with support for authorized requests, People,
|
77
|
+
and Activities
|
76
78
|
test_files: []
|