weibo 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,17 +1,30 @@
1
1
  = weibo
2
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 of how you can use the weibo gem using sinatra.
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 weibo gem.
4
4
 
5
5
 
6
+ To install the gem simply enter:
7
+
6
8
  gem install weibo
7
- git clone git://github.com/ballantyne/weibo.git
8
- cd weibo
9
- ruby example/example.rb
10
- open http://localhost:4567
9
+
10
+ To see an example of how it works enter the following into your terminal:
11
+
12
+ git clone git://github.com/ballantyne/weibo-example.git
13
+ cd weibo-example
14
+ ruby example.rb
11
15
 
12
16
  Most of the 新浪微博 api is implemented by this gem. If I missed something, or Sina added something, please feel free to fork it and add it yourself. I will do my best to keep the gem up to date.
13
17
 
14
- This gem was made in the process of creating {{叽叽喳喳.de}[http://jjzz.de], please take a moment and go and check out that project. I think that it is a very usful tool for interacting with 新浪微博.
18
+ This gem was made in the process of creating {叽叽喳喳.de}[http://jjzz.de], please take a moment and go and check out that project. I think that it is a very useful tool for interacting with 新浪微博.
19
+
20
+ == Sites using the Weibo gem
21
+ * {叽叽喳喳.de}[http://jjzz.de]
22
+
23
+ (Please let me know if your site is using the gem so I can list you here)
24
+
25
+ == Contributors
26
+ * {Feixiong Li}[http://github.com/feixionglee]
27
+ * {Aaron Qian}[http://github.com/aq1018]
15
28
 
16
29
  == Note on Patches/Pull Requests
17
30
 
@@ -20,14 +33,9 @@ This gem was made in the process of creating {{叽叽喳喳.de}[http://jjzz.de],
20
33
  * Add tests for it. This is important so I don't break it in a
21
34
  future version unintentionally.
22
35
  * Commit, do not mess with rakefile, version, or history.
23
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
36
+ (if you want to have your own version, that is fine but bump version in a commit by itself so I can ignore when I pull)
24
37
  * Send me a pull request. Bonus points for topic branches.
25
38
 
26
- == Sites using the Weibo gem
27
- * {叽叽喳喳.de}[http://jjzz.de]
28
-
29
- (Please let me know if your site is using the gem so I can list you here)
30
-
31
39
  == Special Thanks
32
40
  This library was based upon and is an adaptation of John Nunemaker's twitter gem. It started as the twitter gem and has been adapted in the necessary ways to make it work with t.sina.com.cn's api. I'm using it with his blessing, thanks John.
33
41
 
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ begin
7
7
  gem.name = "weibo"
8
8
  gem.summary = %Q{a gem to help api integration for 新浪微博 (t.sina.com.cn)}
9
9
  gem.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.}
10
- gem.email = "scott@ekohe.com"
10
+ gem.email = "ussballantyne@gmail.com"
11
11
  gem.homepage = "http://github.com/ballantyne/weibo"
12
12
  gem.authors = ["Scott Ballantyne"]
13
13
  gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -268,6 +268,11 @@ module Weibo
268
268
  perform_get('/help/test.json')
269
269
  end
270
270
 
271
+ # Trends/daily
272
+ def trends_daily(query={})
273
+ perform_get("/trends/daily.json", :query => query)
274
+ end
275
+
271
276
  protected
272
277
  def self.mime_type(file)
273
278
  case
@@ -1,6 +1,17 @@
1
1
  # This hack is used for Weibo upload
2
2
  # as Sina Weibo doesn't follow the god damned OAuth specifications!!!
3
3
 
4
+ unless {}.respond_to?(:stringify_keys)
5
+ class Hash
6
+ def stringify_keys
7
+ inject({}) do |options, (key, value)|
8
+ options[key.to_s] = value
9
+ options
10
+ end
11
+ end
12
+ end
13
+ end
14
+
4
15
  module PostBodyHack
5
16
  @@parameters = nil
6
17
  def self.parameters=(val)
@@ -23,7 +23,7 @@ module Weibo
23
23
 
24
24
  def initialize(client, method, path, options={})
25
25
  @client, @method, @path, @options = client, method, path, {:mash => true, :query => {:source => Weibo::Config.api_key}}.merge(options)
26
- puts @options.inspect
26
+ # puts @options.inspect
27
27
  end
28
28
 
29
29
 
@@ -1,58 +1,52 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{weibo}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Scott Ballantyne"]
12
- s.date = %q{2010-08-22}
12
+ s.date = %q{2010-12-31}
13
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{scott@ekohe.com}
14
+ s.email = %q{ussballantyne@gmail.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
- "README.rdoc"
17
+ "README.rdoc"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
- ".gitignore",
22
- "LICENSE",
23
- "README.rdoc",
24
- "Rakefile",
25
- "VERSION",
26
- "example/example.rb",
27
- "example/views/index.haml",
28
- "example/views/layout.haml",
29
- "example/views/screen.sass",
30
- "lib/weibo.rb",
31
- "lib/weibo/base.rb",
32
- "lib/weibo/config.rb",
33
- "lib/weibo/httpauth.rb",
34
- "lib/weibo/oauth.rb",
35
- "lib/weibo/oauth_hack.rb",
36
- "lib/weibo/request.rb",
37
- "test/helper.rb",
38
- "test/test_weibo.rb",
39
- "weibo.gemspec"
21
+ "LICENSE",
22
+ "README.rdoc",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "lib/weibo.rb",
26
+ "lib/weibo/base.rb",
27
+ "lib/weibo/config.rb",
28
+ "lib/weibo/httpauth.rb",
29
+ "lib/weibo/oauth.rb",
30
+ "lib/weibo/oauth_hack.rb",
31
+ "lib/weibo/request.rb",
32
+ "test/helper.rb",
33
+ "test/test_weibo.rb",
34
+ "weibo.gemspec"
40
35
  ]
41
36
  s.homepage = %q{http://github.com/ballantyne/weibo}
42
- s.rdoc_options = ["--charset=UTF-8"]
43
37
  s.require_paths = ["lib"]
44
- s.rubygems_version = %q{1.3.6}
38
+ s.rubygems_version = %q{1.3.7}
45
39
  s.summary = %q{a gem to help api integration for 新浪微博 (t.sina.com.cn)}
46
40
  s.test_files = [
47
41
  "test/helper.rb",
48
- "test/test_weibo.rb"
42
+ "test/test_weibo.rb"
49
43
  ]
50
44
 
51
45
  if s.respond_to? :specification_version then
52
46
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
53
47
  s.specification_version = 3
54
48
 
55
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
49
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
56
50
  s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
57
51
  s.add_runtime_dependency(%q<oauth>, ["~> 0.4.1"])
58
52
  s.add_runtime_dependency(%q<hashie>, [">= 0"])
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weibo
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 25
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 2
9
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
10
11
  platform: ruby
11
12
  authors:
12
13
  - Scott Ballantyne
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-08-22 00:00:00 +08:00
18
+ date: 2010-12-31 00:00:00 +08:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: thoughtbot-shoulda
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 3
27
30
  segments:
28
31
  - 0
29
32
  version: "0"
@@ -33,9 +36,11 @@ dependencies:
33
36
  name: oauth
34
37
  prerelease: false
35
38
  requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
36
40
  requirements:
37
41
  - - ~>
38
42
  - !ruby/object:Gem::Version
43
+ hash: 13
39
44
  segments:
40
45
  - 0
41
46
  - 4
@@ -47,9 +52,11 @@ dependencies:
47
52
  name: hashie
48
53
  prerelease: false
49
54
  requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
50
56
  requirements:
51
57
  - - ">="
52
58
  - !ruby/object:Gem::Version
59
+ hash: 3
53
60
  segments:
54
61
  - 0
55
62
  version: "0"
@@ -59,9 +66,11 @@ dependencies:
59
66
  name: httparty
60
67
  prerelease: false
61
68
  requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
62
70
  requirements:
63
71
  - - ">="
64
72
  - !ruby/object:Gem::Version
73
+ hash: 15
65
74
  segments:
66
75
  - 0
67
76
  - 5
@@ -70,7 +79,7 @@ dependencies:
70
79
  type: :runtime
71
80
  version_requirements: *id004
72
81
  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."
73
- email: scott@ekohe.com
82
+ email: ussballantyne@gmail.com
74
83
  executables: []
75
84
 
76
85
  extensions: []
@@ -80,15 +89,10 @@ extra_rdoc_files:
80
89
  - README.rdoc
81
90
  files:
82
91
  - .document
83
- - .gitignore
84
92
  - LICENSE
85
93
  - README.rdoc
86
94
  - Rakefile
87
95
  - VERSION
88
- - example/example.rb
89
- - example/views/index.haml
90
- - example/views/layout.haml
91
- - example/views/screen.sass
92
96
  - lib/weibo.rb
93
97
  - lib/weibo/base.rb
94
98
  - lib/weibo/config.rb
@@ -104,28 +108,32 @@ homepage: http://github.com/ballantyne/weibo
104
108
  licenses: []
105
109
 
106
110
  post_install_message:
107
- rdoc_options:
108
- - --charset=UTF-8
111
+ rdoc_options: []
112
+
109
113
  require_paths:
110
114
  - lib
111
115
  required_ruby_version: !ruby/object:Gem::Requirement
116
+ none: false
112
117
  requirements:
113
118
  - - ">="
114
119
  - !ruby/object:Gem::Version
120
+ hash: 3
115
121
  segments:
116
122
  - 0
117
123
  version: "0"
118
124
  required_rubygems_version: !ruby/object:Gem::Requirement
125
+ none: false
119
126
  requirements:
120
127
  - - ">="
121
128
  - !ruby/object:Gem::Version
129
+ hash: 3
122
130
  segments:
123
131
  - 0
124
132
  version: "0"
125
133
  requirements: []
126
134
 
127
135
  rubyforge_project:
128
- rubygems_version: 1.3.6
136
+ rubygems_version: 1.3.7
129
137
  signing_key:
130
138
  specification_version: 3
131
139
  summary: "a gem to help api integration for \xE6\x96\xB0\xE6\xB5\xAA\xE5\xBE\xAE\xE5\x8D\x9A (t.sina.com.cn)"
data/.gitignore DELETED
@@ -1,21 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC
@@ -1,58 +0,0 @@
1
- %w(rubygems sinatra haml sass oauth pp json).each { |dependency| require dependency }
2
- require File.join(File.dirname(__FILE__), '..', 'lib', 'weibo')
3
- enable :sessions
4
- Weibo::Config.api_key = "2942145647"
5
- Weibo::Config.api_secret = "5cc0026c470a25a6070237e07ade5f27"
6
-
7
- get '/' do
8
- if session[:atoken]
9
- redirect "/friends_timeline"
10
- end
11
- haml :index
12
- end
13
-
14
- get "/friends_timeline" do
15
- oauth = Weibo::OAuth.new(Weibo::Config.api_key, Weibo::Config.api_secret)
16
- oauth.authorize_from_access(session[:atoken], session[:asecret])
17
- @timeline = Weibo::Base.new(oauth).friends_timeline
18
- haml :index
19
- end
20
-
21
- get "/friends_timeline.json" do
22
- content_type :json
23
- oauth = Weibo::OAuth.new(Weibo::Config.api_key, Weibo::Config.api_secret)
24
- oauth.authorize_from_access(session[:atoken], session[:asecret])
25
- Weibo::Base.new(oauth).friends_timeline.to_json
26
- end
27
-
28
- post '/update' do
29
- oauth = Weibo::OAuth.new(Weibo::Config.api_key, Weibo::Config.api_secret)
30
- oauth.authorize_from_access(session[:atoken], session[:asecret])
31
- Weibo::Base.new(oauth).update(params[:update])
32
- redirect "/friends_timeline"
33
- end
34
-
35
- get '/connect' do
36
- oauth = Weibo::OAuth.new(Weibo::Config.api_key, Weibo::Config.api_secret)
37
- request_token = oauth.consumer.get_request_token
38
- session[:rtoken], session[:rsecret] = request_token.token, request_token.secret
39
- redirect "#{request_token.authorize_url}&oauth_callback=http://localhost:4567/callback"
40
- end
41
-
42
- get '/callback' do
43
- oauth = Weibo::OAuth.new(Weibo::Config.api_key, Weibo::Config.api_secret)
44
- oauth.authorize_from_request(session[:rtoken], session[:rsecret], params[:oauth_verifier])
45
- session[:rtoken], session[:rsecret] = nil, nil
46
- session[:atoken], session[:asecret] = oauth.access_token.token, oauth.access_token.secret
47
- redirect "/"
48
- end
49
-
50
- get '/logout' do
51
- session[:atoken], session[:asecret] = nil, nil
52
- redirect "/"
53
- end
54
-
55
- get '/screen.css' do
56
- content_type 'text/css'
57
- sass :screen
58
- end
@@ -1,32 +0,0 @@
1
- -if session[:atoken]
2
- %form{:action => "/update", :method => "POST"}
3
- %textarea{:name => "update", :cols => "62", :rows => "5"}
4
- %br
5
- %input{:type => "submit", :value => "Send"}
6
- %h1
7
- friends_timeline
8
- -@timeline.each do |weibo|
9
- .weibo
10
- %img{:src => weibo.user.profile_image_url, :class => "avatar" }
11
- %span.text
12
- %a{:href => "http://t.sina.com.cn/#{weibo.user.id}", :target => "_blank"}=weibo.user.screen_name
13
- %span=weibo.text
14
- %br
15
- %span=weibo.created_at
16
- -if weibo.thumbnail_pic
17
- %br
18
- %a{:href => weibo.original_pic, :target => "_blank"}
19
- %img{:src => weibo.thumbnail_pic, :class => "thumbnail_pic", :alt => weibo.original_pic}
20
- -if weibo.retweeted_status
21
- .retweeted_status
22
- %img{:src => weibo.retweeted_status.user.profile_image_url, :class => "avatar" }
23
- %span.text
24
- %a{:href => "http://t.sina.com.cn/#{weibo.user.id}", :target => "_blank"}=weibo.retweeted_status.user.screen_name
25
- %span=weibo.retweeted_status.text
26
- %br
27
- %span=weibo.retweeted_status.created_at
28
- -if weibo.retweeted_status.thumbnail_pic
29
- %br
30
- %a{:href => weibo.retweeted_status.original_pic, :target => "_blank"}
31
- %img{:src => weibo.retweeted_status.thumbnail_pic, :class => "thumbnail_pic", :alt => weibo.retweeted_status.original_pic}
32
-
@@ -1,10 +0,0 @@
1
- !!!
2
- %html(xml:lang='en' lang='en' xmlns='http://www.w3.org/1999/xhtml')
3
- %head
4
- %meta(content='text/html;charset=UTF-8' http-equiv='content-type')
5
- %title="weibo gem example"
6
- %link{:href => "/screen.css", :rel =>"stylesheet", :type => "text/css", :media => "screen" }
7
- %body
8
- %h2="weibo gem example"
9
- %a{:href => (session[:atoken] ? "/logout" : "/connect")}=(session[:atoken] ? "logout" : "connect")
10
- = yield
@@ -1,24 +0,0 @@
1
- .weibo
2
- :float left
3
- :clear left
4
- :padding 10px
5
- :width 483px
6
- :border 1px solid #242424
7
- :margin-bottom 10px
8
- img.avatar
9
- :float left
10
- :display inline
11
- span.text
12
- :float left
13
- :display inline
14
- :width 400px
15
- :margin-left 10px
16
- img.thumbnail_pic
17
- :clear left
18
- :float left
19
- .retweeted_status
20
- :background #cccccc
21
- :float left
22
- :clear left
23
- :padding 10px
24
- :border 1px solid #242424