renren 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'httparty'
@@ -0,0 +1,14 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ httparty (0.8.1)
5
+ multi_json
6
+ multi_xml
7
+ multi_json (1.0.4)
8
+ multi_xml (0.4.1)
9
+
10
+ PLATFORMS
11
+ ruby
12
+
13
+ DEPENDENCIES
14
+ httparty
@@ -0,0 +1,14 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec', :version => 2 do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec/" }
8
+ end
9
+
10
+ guard 'cucumber' do
11
+ watch(%r{^features/.+\.feature$})
12
+ watch(%r{^features/support/.+$}) { 'features' }
13
+ watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
14
+ end
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Scott Ballantyne
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,8 @@
1
+ = renren
2
+
3
+ One of the goals of this gem was to have the same syntax as the twitter gem wherever possible so that it would be easy to learn and use. Download the gem and give it a try. Also, I've put together a small demo using sinatra showing how you can use the renren gem.
4
+
5
+
6
+ To install the gem simply enter:
7
+
8
+ gem install renren
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.11
@@ -0,0 +1,13 @@
1
+ # code is an adaptation of the twitter gem by John Nunemaker
2
+ # http://github.com/jnunemaker/twitter
3
+ # Copyright (c) 2009 John Nunemaker
4
+ #
5
+ # made to work with china's facebook, 人人网
6
+
7
+ require 'renren/config'
8
+ require 'renren/base'
9
+ if File.exists?('config/weibo.yml')
10
+ weibo_oauth = YAML.load_file('config/weibo.yml')[Rails.env || env || 'development']
11
+ Weibo::Config.api_key = weibo_oauth["api_key"]
12
+ Weibo::Config.api_secret = weibo_oauth["api_secret"]
13
+ end
@@ -0,0 +1,31 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'uri'
3
+ require 'multi_json'
4
+ require 'net/http'
5
+ require 'digest'
6
+
7
+ module Renren
8
+ class Base
9
+ attr_accessor :params
10
+
11
+ def initialize(access_token)
12
+ @params = {}
13
+ @params[:method] = "friends.get"
14
+ @params[:call_id] = Time.now.to_i
15
+ @params[:format] = 'json'
16
+ @params[:v] = '1.0'
17
+ @params[:access_token] = access_token
18
+ end
19
+
20
+ def call_method(opts = {:method => users.getinfo})
21
+ MultiJson.decode(Net::HTTP.post_form(URI.parse('http://api.renren.com/restserver.do'), update_params(opts)).body)
22
+ end
23
+
24
+ private
25
+ def update_params(opts)
26
+ params = @params.merge(opts){|key, first, second| second}
27
+ params[:sig] = Digest::MD5.hexdigest(params.map{|k,v| "#{k}=#{v}"}.sort.join + Config.api_secret)
28
+ params
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,21 @@
1
+ module Renren
2
+ module Config
3
+
4
+ def self.api_key=(val)
5
+ @@api_key = val
6
+ end
7
+
8
+ def self.api_key
9
+ @@api_key
10
+ end
11
+
12
+ def self.api_secret=(val)
13
+ @@api_secret = val
14
+ end
15
+
16
+ def self.api_secret
17
+ @@api_secret
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,53 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{renren}
8
+ s.version = "0.0.11"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Huang Xiangdan"]
12
+ s.date = %q{2011-11-29}
13
+ s.description = %q{this gem is an adaptation of John Nunemaker's Twitter gem. I modified it to make api integration for 新浪微博 (t.sina.com.cn) easier.}
14
+ s.email = %q{xd_huang1986@163.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ "Gemfile",
21
+ "Gemfile.lock",
22
+ "Guardfile",
23
+ "LICENSE",
24
+ "README.rdoc",
25
+ "VERSION",
26
+ "lib/renren.rb",
27
+ "lib/renren/base.rb",
28
+ "lib/renren/config.rb",
29
+ "renren.gemspec",
30
+ "renren.yml.example"
31
+ ]
32
+ s.homepage = %q{http://github.com/huangxiangdan/renren}
33
+ s.require_paths = ["lib"]
34
+ s.rubygems_version = %q{1.3.7}
35
+ s.summary = %q{a gem to help api integration for renren (www.renren.com)}
36
+
37
+ if s.respond_to? :specification_version then
38
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
39
+ s.specification_version = 3
40
+
41
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
42
+ s.add_runtime_dependency(%q<httparty>, [">= 0"])
43
+ s.add_runtime_dependency(%q<httparty>, [">= 0.5.2"])
44
+ else
45
+ s.add_dependency(%q<httparty>, [">= 0"])
46
+ s.add_dependency(%q<httparty>, [">= 0.5.2"])
47
+ end
48
+ else
49
+ s.add_dependency(%q<httparty>, [">= 0"])
50
+ s.add_dependency(%q<httparty>, [">= 0.5.2"])
51
+ end
52
+ end
53
+
@@ -0,0 +1,9 @@
1
+ development:
2
+ api_key: api_key
3
+ api_secret: api_secret
4
+ test``:
5
+ api_key: api_key
6
+ api_secret: api_secret
7
+ production:
8
+ api_key: api_key
9
+ api_secret: api_secret
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: renren
3
+ version: !ruby/object:Gem::Version
4
+ hash: 9
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 11
10
+ version: 0.0.11
11
+ platform: ruby
12
+ authors:
13
+ - Huang Xiangdan
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-11-29 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: httparty
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: httparty
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 15
43
+ segments:
44
+ - 0
45
+ - 5
46
+ - 2
47
+ version: 0.5.2
48
+ type: :runtime
49
+ version_requirements: *id002
50
+ description: "this gem is an adaptation of John Nunemaker's Twitter gem. I modified it to make api integration for \xE6\x96\xB0\xE6\xB5\xAA\xE5\xBE\xAE\xE5\x8D\x9A (t.sina.com.cn) easier."
51
+ email: xd_huang1986@163.com
52
+ executables: []
53
+
54
+ extensions: []
55
+
56
+ extra_rdoc_files:
57
+ - LICENSE
58
+ - README.rdoc
59
+ files:
60
+ - Gemfile
61
+ - Gemfile.lock
62
+ - Guardfile
63
+ - LICENSE
64
+ - README.rdoc
65
+ - VERSION
66
+ - lib/renren.rb
67
+ - lib/renren/base.rb
68
+ - lib/renren/config.rb
69
+ - renren.gemspec
70
+ - renren.yml.example
71
+ homepage: http://github.com/huangxiangdan/renren
72
+ licenses: []
73
+
74
+ post_install_message:
75
+ rdoc_options: []
76
+
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ hash: 3
85
+ segments:
86
+ - 0
87
+ version: "0"
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ hash: 3
94
+ segments:
95
+ - 0
96
+ version: "0"
97
+ requirements: []
98
+
99
+ rubyforge_project:
100
+ rubygems_version: 1.8.11
101
+ signing_key:
102
+ specification_version: 3
103
+ summary: a gem to help api integration for renren (www.renren.com)
104
+ test_files: []
105
+