renren-mobile 0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'httparty'
4
+ gem 'rest-client'
@@ -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,15 @@
1
+
2
+ A third party, non-official renren API gem created by huangxiangdan. Inspired by ballantyne's weibo API gem.
3
+
4
+ To install the gem simply enter:
5
+
6
+ gem install renren-mobile
7
+
8
+ This is a minimalistic API implementation, where all function calls goes through a single method. For example to publish a feed item one might do the following:
9
+
10
+ param = {:method, "feed.publishFeed", :name, "foo", :description, "bar", :url, "http://jihua.fm"}
11
+ renren = RenrenMobile::Base.new(token)
12
+ renren.call_method(param)
13
+
14
+ == Sites using the renren-mobile gem
15
+ 课程格子 [http://kechengbiao.me]
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1
@@ -0,0 +1,8 @@
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-mobile/config'
8
+ require 'renren-mobile/base'
@@ -0,0 +1,37 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'uri'
3
+ require 'multi_json'
4
+ require 'net/http'
5
+ require 'digest'
6
+ require 'rest_client'
7
+
8
+ module RenrenMobile
9
+ class Base
10
+ attr_accessor :params
11
+
12
+ def initialize(access_token)
13
+ @params = {}
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(method, opts = {})
21
+ method = method.gsub(".", "/")
22
+ MultiJson.decode(Net::HTTP.post_form(URI.parse("http://api.m.renren.com/api/#{method}"), update_params(opts)).body)
23
+ end
24
+
25
+ def upload_file(method, filename, opts = {})
26
+ method = method.gsub(".", "/")
27
+ MultiJson.decode(RestClient.post('http://api.m.renren.com/api/#{method}', update_params(opts).merge(:data => File.new(filename))))
28
+ end
29
+
30
+ private
31
+ def update_params(opts)
32
+ params = @params.merge(opts){|key, first, second| second}
33
+ params[:sig] = Digest::MD5.hexdigest(params.map{|k,v| "#{k}=#{v}"}.sort.join + Config.api_secret)
34
+ params
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,21 @@
1
+ module RenrenMobile
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,55 @@
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-mobile}
8
+ s.version = "0.1"
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{2012-11-18}
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-mobile.rb",
27
+ "lib/renren-mobile/base.rb",
28
+ "lib/renren-mobile/config.rb",
29
+ "renren-mobile.gemspec",
30
+ ]
31
+ s.homepage = %q{http://github.com/huangxiangdan/renren-mobile}
32
+ s.require_paths = ["lib"]
33
+ s.rubygems_version = %q{1.3.7}
34
+ s.summary = %q{a gem to help api integration for renren-mobile (http://wiki.mobile.renren.com/)}
35
+
36
+ if s.respond_to? :specification_version then
37
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
38
+ s.specification_version = 3
39
+
40
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
41
+ s.add_runtime_dependency(%q<httparty>, [">= 0"])
42
+ s.add_runtime_dependency(%q<httparty>, [">= 0.5.2"])
43
+ s.add_runtime_dependency(%q<rest-client>, [">= 1.6.7"])
44
+ else
45
+ s.add_dependency(%q<httparty>, [">= 0"])
46
+ s.add_dependency(%q<httparty>, [">= 0.5.2"])
47
+ s.add_dependency(%q<rest-client>, [">= 1.6.7"])
48
+ end
49
+ else
50
+ s.add_dependency(%q<httparty>, [">= 0"])
51
+ s.add_dependency(%q<httparty>, [">= 0.5.2"])
52
+ s.add_dependency(%q<rest-client>, [">= 1.6.7"])
53
+ end
54
+ end
55
+
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: renren-mobile
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Huang Xiangdan
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: httparty
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: httparty
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 0.5.2
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 0.5.2
46
+ - !ruby/object:Gem::Dependency
47
+ name: rest-client
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 1.6.7
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.6.7
62
+ description: this gem is an adaptation of John Nunemaker's Twitter gem. I modified
63
+ it to make api integration for 新浪微博 (t.sina.com.cn) easier.
64
+ email: xd_huang1986@163.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files:
68
+ - LICENSE
69
+ - README.rdoc
70
+ files:
71
+ - Gemfile
72
+ - Gemfile.lock
73
+ - Guardfile
74
+ - LICENSE
75
+ - README.rdoc
76
+ - VERSION
77
+ - lib/renren-mobile.rb
78
+ - lib/renren-mobile/base.rb
79
+ - lib/renren-mobile/config.rb
80
+ - renren-mobile.gemspec
81
+ homepage: http://github.com/huangxiangdan/renren-mobile
82
+ licenses: []
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ! '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubyforge_project:
101
+ rubygems_version: 1.8.24
102
+ signing_key:
103
+ specification_version: 3
104
+ summary: a gem to help api integration for renren-mobile (http://wiki.mobile.renren.com/)
105
+ test_files: []