sina 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/Gemfile.lock +18 -0
- data/LICENSE +20 -0
- data/README.rdoc +19 -0
- data/VERSION +1 -0
- data/lib/sina/base.rb +30 -0
- data/lib/sina/config.rb +21 -0
- data/lib/sina.rb +13 -0
- data/sina.gemspec +55 -0
- data/sina.yml.example +9 -0
- metadata +104 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
httparty (0.8.1)
|
5
|
+
multi_json
|
6
|
+
multi_xml
|
7
|
+
mime-types (1.19)
|
8
|
+
multi_json (1.0.4)
|
9
|
+
multi_xml (0.4.1)
|
10
|
+
rest-client (1.6.7)
|
11
|
+
mime-types (>= 1.16)
|
12
|
+
|
13
|
+
PLATFORMS
|
14
|
+
ruby
|
15
|
+
|
16
|
+
DEPENDENCIES
|
17
|
+
httparty
|
18
|
+
rest-client
|
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.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
A third party, non-official sina weibo API gem created by goshan. Inspired by huangxiangdan's renren API gem.
|
3
|
+
|
4
|
+
To install the gem simply enter:
|
5
|
+
|
6
|
+
gem install sina
|
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 = {:uid => "blahblah"}
|
11
|
+
sina = Sina::Base.new(token)
|
12
|
+
sina.call_method("users/show", param)
|
13
|
+
|
14
|
+
the token should be got by yourself
|
15
|
+
|
16
|
+
This gem was made in the process of creating 一见关注 [http://easyfollow.com], please take a moment and go and check out that project for example usage.
|
17
|
+
|
18
|
+
== Sites using the renren gem
|
19
|
+
easyFollow http://easyfollow.com
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.13
|
data/lib/sina/base.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'uri'
|
3
|
+
require 'multi_json'
|
4
|
+
require 'net/http'
|
5
|
+
require 'net/https'
|
6
|
+
require 'digest'
|
7
|
+
require 'rest_client'
|
8
|
+
|
9
|
+
module Sina
|
10
|
+
class Base
|
11
|
+
attr_accessor :params
|
12
|
+
|
13
|
+
def initialize(access_token)
|
14
|
+
@access_token = access_token
|
15
|
+
end
|
16
|
+
|
17
|
+
def call_method(function = "users/show", params)
|
18
|
+
url = URI.parse("https://api.weibo.com/2/#{function}.json")
|
19
|
+
http = Net::HTTP.new(url.host, url.port)
|
20
|
+
http.use_ssl = true if url.scheme == 'https'
|
21
|
+
request = Net::HTTP::Get.new("#{url.path}?access_token=#{@access_token}&#{params_to_string(params)}")
|
22
|
+
MultiJson.decode(http.request(request).body)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
def params_to_string(params)
|
27
|
+
params.map{|key, value| "#{key}=#{value}"}.join("&")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/sina/config.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module Sina
|
2
|
+
module Config
|
3
|
+
|
4
|
+
def self.app_key=(val)
|
5
|
+
@@app_key = val
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.app_key
|
9
|
+
@@app_key
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.scret_key=(val)
|
13
|
+
@@scret_key = val
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.scret_key
|
17
|
+
@@scret_key
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
data/lib/sina.rb
ADDED
@@ -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 'sina/config'
|
8
|
+
require 'sina/base'
|
9
|
+
if File.exists?('config/sina.yml')
|
10
|
+
weibo_oauth = YAML.load_file('config/weibo.yml')[Rails.env || env || 'development']
|
11
|
+
Sina::Config.app_key = weibo_oauth["app_key"]
|
12
|
+
Sina::Config.scret_key = weibo_oauth["scret_key"]
|
13
|
+
end
|
data/sina.gemspec
ADDED
@@ -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{sina}
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["goshan"]
|
12
|
+
s.date = %q{2012-10-17}
|
13
|
+
s.description = %q{this gem is a simple one for call for sina weibo api}
|
14
|
+
s.email = %q{goshan.hanqiu@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
"Gemfile",
|
21
|
+
"Gemfile.lock",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"VERSION",
|
25
|
+
"lib/sina.rb",
|
26
|
+
"lib/sina/base.rb",
|
27
|
+
"lib/sina/config.rb",
|
28
|
+
"sina.gemspec",
|
29
|
+
"sina.yml.example"
|
30
|
+
]
|
31
|
+
s.homepage = %q{http://github.com/goshan/sina_weibo}
|
32
|
+
s.require_paths = ["lib"]
|
33
|
+
s.rubygems_version = %q{1.3.7}
|
34
|
+
s.summary = %q{a gem to help api integration for sina weibo (www.weibo.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
|
+
|
data/sina.yml.example
ADDED
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sina
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- goshan
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-10-17 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 a simple one for call for sina weibo api
|
63
|
+
email: goshan.hanqiu@gmail.com
|
64
|
+
executables: []
|
65
|
+
extensions: []
|
66
|
+
extra_rdoc_files:
|
67
|
+
- LICENSE
|
68
|
+
- README.rdoc
|
69
|
+
files:
|
70
|
+
- Gemfile
|
71
|
+
- Gemfile.lock
|
72
|
+
- LICENSE
|
73
|
+
- README.rdoc
|
74
|
+
- VERSION
|
75
|
+
- lib/sina.rb
|
76
|
+
- lib/sina/base.rb
|
77
|
+
- lib/sina/config.rb
|
78
|
+
- sina.gemspec
|
79
|
+
- sina.yml.example
|
80
|
+
homepage: http://github.com/goshan/sina_weibo
|
81
|
+
licenses: []
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options: []
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ! '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
94
|
+
requirements:
|
95
|
+
- - ! '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubyforge_project:
|
100
|
+
rubygems_version: 1.8.24
|
101
|
+
signing_key:
|
102
|
+
specification_version: 3
|
103
|
+
summary: a gem to help api integration for sina weibo (www.weibo.com)
|
104
|
+
test_files: []
|