gilesbowkett-twitter 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History +126 -0
- data/License +19 -0
- data/Manifest +69 -0
- data/README +84 -0
- data/Rakefile +42 -0
- data/bin/twitter +14 -0
- data/examples/blocks.rb +15 -0
- data/examples/direct_messages.rb +29 -0
- data/examples/favorites.rb +20 -0
- data/examples/friends_followers.rb +25 -0
- data/examples/friendships.rb +13 -0
- data/examples/identica_timeline.rb +7 -0
- data/examples/location.rb +8 -0
- data/examples/posting.rb +9 -0
- data/examples/replies.rb +27 -0
- data/examples/search.rb +18 -0
- data/examples/sent_messages.rb +27 -0
- data/examples/timeline.rb +34 -0
- data/examples/twitter.rb +27 -0
- data/examples/verify_credentials.rb +13 -0
- data/lib/twitter/base.rb +284 -0
- data/lib/twitter/cli/config.rb +9 -0
- data/lib/twitter/cli/helpers.rb +109 -0
- data/lib/twitter/cli/migrations/20080722194500_create_accounts.rb +13 -0
- data/lib/twitter/cli/migrations/20080722194508_create_tweets.rb +16 -0
- data/lib/twitter/cli/migrations/20080722214605_add_account_id_to_tweets.rb +9 -0
- data/lib/twitter/cli/migrations/20080722214606_create_configurations.rb +13 -0
- data/lib/twitter/cli/models/account.rb +33 -0
- data/lib/twitter/cli/models/configuration.rb +13 -0
- data/lib/twitter/cli/models/tweet.rb +20 -0
- data/lib/twitter/cli.rb +334 -0
- data/lib/twitter/direct_message.rb +30 -0
- data/lib/twitter/easy_class_maker.rb +43 -0
- data/lib/twitter/rate_limit_status.rb +19 -0
- data/lib/twitter/search.rb +101 -0
- data/lib/twitter/search_result.rb +83 -0
- data/lib/twitter/search_result_info.rb +82 -0
- data/lib/twitter/status.rb +22 -0
- data/lib/twitter/user.rb +37 -0
- data/lib/twitter/version.rb +3 -0
- data/lib/twitter.rb +32 -0
- data/spec/base_spec.rb +139 -0
- data/spec/cli/helper_spec.rb +49 -0
- data/spec/direct_message_spec.rb +40 -0
- data/spec/fixtures/follower_ids.xml +11 -0
- data/spec/fixtures/followers.xml +706 -0
- data/spec/fixtures/friend_ids.xml +12 -0
- data/spec/fixtures/friends.xml +609 -0
- data/spec/fixtures/friends_for.xml +584 -0
- data/spec/fixtures/friends_lite.xml +192 -0
- data/spec/fixtures/friends_timeline.xml +66 -0
- data/spec/fixtures/friendship_already_exists.xml +5 -0
- data/spec/fixtures/friendship_created.xml +12 -0
- data/spec/fixtures/public_timeline.xml +148 -0
- data/spec/fixtures/rate_limit_status.xml +7 -0
- data/spec/fixtures/search_result_info.yml +147 -0
- data/spec/fixtures/search_results.json +1 -0
- data/spec/fixtures/status.xml +25 -0
- data/spec/fixtures/user.xml +38 -0
- data/spec/fixtures/user_timeline.xml +465 -0
- data/spec/search_spec.rb +100 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +23 -0
- data/spec/status_spec.rb +40 -0
- data/spec/user_spec.rb +42 -0
- data/twitter.gemspec +45 -0
- data/website/css/common.css +47 -0
- data/website/images/terminal_output.png +0 -0
- data/website/index.html +147 -0
- metadata +188 -0
data/History
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
0.4.2 - February 10, 2009
|
2
|
+
* 1 minor enhancement
|
3
|
+
* Adding the Social Graph API methods (Josh Owens)
|
4
|
+
|
5
|
+
0.4.1 - January 1, 2009
|
6
|
+
* 4 minor enhancements and 2 bug fixes:
|
7
|
+
* Added better exception handling (Billy Gray)
|
8
|
+
* Added page to search (Michael Ivey)
|
9
|
+
* Adding an option to display tweets on CLI in reverse order (oldest first). (Cameron Booth)
|
10
|
+
* Added in_reply_to_status_id option for replying to statuses (anthonycrumley)
|
11
|
+
* Fixed a bug where the @config was improperly set (K. Adam Christensen)
|
12
|
+
* Fix verify_credentials to include a format (breaks in laconica). (dustin)
|
13
|
+
|
14
|
+
0.4.0 - December 23, 2008
|
15
|
+
* 3 major changes
|
16
|
+
* Removed active support as dependency
|
17
|
+
* Removed CLI dependencies from install dependency list
|
18
|
+
(they are now only installed by you manually)
|
19
|
+
* Switched to echoe for gem managment
|
20
|
+
|
21
|
+
0.3.7 - August 26, 2008
|
22
|
+
* Fixed source param not getting through
|
23
|
+
|
24
|
+
0.3.6 - August 11, 2008
|
25
|
+
* Fixed a few more methods that required post.
|
26
|
+
* Refactored the remaining methods that were not using #request to use it.
|
27
|
+
|
28
|
+
0.3.5 - August 4, 2008
|
29
|
+
* Removed sqlite-ruby 1.2.2 as a dependency due to install issues on linux
|
30
|
+
|
31
|
+
0.3.4 - August 3, 2008
|
32
|
+
* Added search support
|
33
|
+
|
34
|
+
0.3.3 - August 3, 2008
|
35
|
+
* Now has option for host when initializing to support identi.ca (Dustin Sallings)
|
36
|
+
* Twitter changed a bunch of methods to POST only so I updated those to now work
|
37
|
+
|
38
|
+
0.3.2 - July 26, 2008
|
39
|
+
* added the CLI gems as dependencies for now until I separate out the CLI from the API wrapper
|
40
|
+
* cleaner CLI errors for no active account or no accounts at all
|
41
|
+
* remove sets a new active account if there are none
|
42
|
+
* added username and password optional arguments to add
|
43
|
+
* added import attempt on install and on anything that uses #current_account helper
|
44
|
+
|
45
|
+
0.3.1 - July 23, 2008
|
46
|
+
* added open to CLI twitter open jnunemaker would open default browser to http://twitter.com/jnunemaker
|
47
|
+
* added -f to timeline and replies which ignores the since_id and shows all results
|
48
|
+
* added clear_config to remove all cached since id's and such
|
49
|
+
* Majorly pimped the output of timelines and replies.
|
50
|
+
|
51
|
+
0.3.0 - July 22, 2008
|
52
|
+
* complete rewrite of CLI. Now supports multiple accounts and changing between them.
|
53
|
+
* added source, truncated, in_reply_to_status_id, in_reply_to_user_id, and favorited to Twitter::Status
|
54
|
+
* added protected to Twitter::User
|
55
|
+
* d CLI method now takes standard input like post
|
56
|
+
* Rewrote several methods that had since parameter to now use a hash instead. This makes it more flexible as API updates.
|
57
|
+
* Rewrote the methods that took lite or since as an argument to instead take a hash.
|
58
|
+
* added Twitter::Base#friendship_exists?
|
59
|
+
* added Twitter::Base#update_location
|
60
|
+
* added Twitter::Base#update_delivery_device
|
61
|
+
* added Twitter::Base#favorites
|
62
|
+
* added Twitter::Base#create_favorite
|
63
|
+
* added Twitter::Base#destroy_favorite
|
64
|
+
* added Twitter::Base#block
|
65
|
+
* added Twitter::Base#unblock
|
66
|
+
|
67
|
+
BACKWORDS COMPATIBILITY BREAK:
|
68
|
+
Any method that you have using lite or since as an argument
|
69
|
+
will no longer work with this version. Simply change to a
|
70
|
+
hash and you'll be fine. For example:
|
71
|
+
|
72
|
+
friends(true) would now be friends(:lite => true)
|
73
|
+
|
74
|
+
0.2.7 - June 29, 2008
|
75
|
+
* added #rate_limit_status (Daniel Morrison)
|
76
|
+
* added source parameter option to Base#post
|
77
|
+
* added twittergem as source when posting from command line
|
78
|
+
* Twitter::RateExceeded raised when you hit your limit (Jim O'Leary)
|
79
|
+
* Twitter::Unavailable raised when twitter returns 503
|
80
|
+
* Twitter::CantConnect is now more descriptive as to what is the problem when it is raised during a request
|
81
|
+
* quoting your message when using twitter post on the command line is now optional (Benoit Caccinolo)
|
82
|
+
* aliased post to p on command line so it's shorter (Benoit Caccinolo)
|
83
|
+
* unescaped html and added some color in command line view (Miles Z. Sterrett)
|
84
|
+
* added gemspec (technoweenie, Miles Z. Sterrett)
|
85
|
+
* Fixed stack trace error on first command line operation (Matt Rose)
|
86
|
+
0.2.6 - April 2, 2008
|
87
|
+
* found a more simple way of doing stdin without any extra gem dependencies
|
88
|
+
0.2.5 - April 2, 2008
|
89
|
+
* Command line interface can now use stdin for posting (ideas and example code from Jeremy Friesen)
|
90
|
+
$ twitter post 'test without stdin' # => twitters: test without stdin
|
91
|
+
$ echo 'test with stdin' | twitter post 'and an argv[1]' # => twitters: test with stdin and an argv[1]
|
92
|
+
$ echo 'test with stdin without any argv[1]' | twitter post # => twitters: test with stdin without any argv[1]
|
93
|
+
0.2.4 - Mar 31, 2008
|
94
|
+
* Added lite option to friends and followers, which doesn't include the user's current status (Daniel Morrison)
|
95
|
+
* Updated since option to use HTTP header, and added the option on timeline() and replies(). (Daniel Morrison)
|
96
|
+
0.2.3 - Jan 16, 2008
|
97
|
+
* added d to command line interface twitter d jnunemaker 'hola' (Humbucker)
|
98
|
+
* added progress dots when posting for confirmation when twitter is running slow (Hendy Irawan)
|
99
|
+
0.2.2 - added leave and follow which are new twitter api methods for turning notifications on and off
|
100
|
+
0.2.0 - Aug 4, 2007
|
101
|
+
* added sent_messages
|
102
|
+
* alias direct_messages to received_messages
|
103
|
+
* added create_friendship
|
104
|
+
* added destroy_friendship
|
105
|
+
* added featured to retrieve the featured twitter users
|
106
|
+
* added replies
|
107
|
+
* added destroy to destroy a status by id
|
108
|
+
* added status to find a status by id
|
109
|
+
* added active support as an extra dependency
|
110
|
+
* implemented d method to send direct messages (jnewland)
|
111
|
+
* fixed since argument in direct_messages method (jnewland)
|
112
|
+
0.1.1 - May 20, 2007
|
113
|
+
* hpricot 0.5+ now supported; just a bug fix (Ryan Waldron is the man!)
|
114
|
+
0.1.0 - March 31, 2007
|
115
|
+
* added d method for creating direct messages (waiting for it to work as documented)
|
116
|
+
* added featured method for getting featured users statuses (waiting for it to work as documented)
|
117
|
+
* added direct_messages method
|
118
|
+
* added friends_for method
|
119
|
+
* added a few tests
|
120
|
+
* removed relative_created_at as it is deprecated
|
121
|
+
* separated out the call method into call, request and parse methods
|
122
|
+
0.0.5 - just a bit of code cleanup
|
123
|
+
0.0.4 - added :location, :description, :url, :profile_image_url to user class (Alex Payne)
|
124
|
+
0.0.3 - added a bit more informative message when things go wrong
|
125
|
+
0.0.2 - added the command line options i forgot to add (friend and follower); improved some docs
|
126
|
+
0.0.1 - initial release
|
data/License
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2007 John Nunemaker
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/Manifest
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
bin/twitter
|
2
|
+
examples/blocks.rb
|
3
|
+
examples/direct_messages.rb
|
4
|
+
examples/favorites.rb
|
5
|
+
examples/friends_followers.rb
|
6
|
+
examples/friendships.rb
|
7
|
+
examples/identica_timeline.rb
|
8
|
+
examples/location.rb
|
9
|
+
examples/posting.rb
|
10
|
+
examples/replies.rb
|
11
|
+
examples/search.rb
|
12
|
+
examples/sent_messages.rb
|
13
|
+
examples/timeline.rb
|
14
|
+
examples/twitter.rb
|
15
|
+
examples/verify_credentials.rb
|
16
|
+
History
|
17
|
+
lib/twitter/base.rb
|
18
|
+
lib/twitter/cli/config.rb
|
19
|
+
lib/twitter/cli/helpers.rb
|
20
|
+
lib/twitter/cli/migrations/20080722194500_create_accounts.rb
|
21
|
+
lib/twitter/cli/migrations/20080722194508_create_tweets.rb
|
22
|
+
lib/twitter/cli/migrations/20080722214605_add_account_id_to_tweets.rb
|
23
|
+
lib/twitter/cli/migrations/20080722214606_create_configurations.rb
|
24
|
+
lib/twitter/cli/models/account.rb
|
25
|
+
lib/twitter/cli/models/configuration.rb
|
26
|
+
lib/twitter/cli/models/tweet.rb
|
27
|
+
lib/twitter/cli.rb
|
28
|
+
lib/twitter/direct_message.rb
|
29
|
+
lib/twitter/easy_class_maker.rb
|
30
|
+
lib/twitter/rate_limit_status.rb
|
31
|
+
lib/twitter/search.rb
|
32
|
+
lib/twitter/search_result.rb
|
33
|
+
lib/twitter/search_result_info.rb
|
34
|
+
lib/twitter/status.rb
|
35
|
+
lib/twitter/user.rb
|
36
|
+
lib/twitter/version.rb
|
37
|
+
lib/twitter.rb
|
38
|
+
License
|
39
|
+
Manifest
|
40
|
+
Rakefile
|
41
|
+
README
|
42
|
+
spec/base_spec.rb
|
43
|
+
spec/cli/helper_spec.rb
|
44
|
+
spec/direct_message_spec.rb
|
45
|
+
spec/fixtures/follower_ids.xml
|
46
|
+
spec/fixtures/followers.xml
|
47
|
+
spec/fixtures/friend_ids.xml
|
48
|
+
spec/fixtures/friends.xml
|
49
|
+
spec/fixtures/friends_for.xml
|
50
|
+
spec/fixtures/friends_lite.xml
|
51
|
+
spec/fixtures/friends_timeline.xml
|
52
|
+
spec/fixtures/friendship_already_exists.xml
|
53
|
+
spec/fixtures/friendship_created.xml
|
54
|
+
spec/fixtures/public_timeline.xml
|
55
|
+
spec/fixtures/rate_limit_status.xml
|
56
|
+
spec/fixtures/search_result_info.yml
|
57
|
+
spec/fixtures/search_results.json
|
58
|
+
spec/fixtures/status.xml
|
59
|
+
spec/fixtures/user.xml
|
60
|
+
spec/fixtures/user_timeline.xml
|
61
|
+
spec/search_spec.rb
|
62
|
+
spec/spec.opts
|
63
|
+
spec/spec_helper.rb
|
64
|
+
spec/status_spec.rb
|
65
|
+
spec/user_spec.rb
|
66
|
+
twitter.gemspec
|
67
|
+
website/css/common.css
|
68
|
+
website/images/terminal_output.png
|
69
|
+
website/index.html
|
data/README
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
= addicted to twitter
|
2
|
+
|
3
|
+
... a sweet little diddy that helps you twitter your life away
|
4
|
+
|
5
|
+
== Install
|
6
|
+
|
7
|
+
sudo gem install twitter will work just fine. For command line use, you'll need a few other gems: sudo gem install main highline activerecord sqlite3-ruby
|
8
|
+
|
9
|
+
== Examples
|
10
|
+
|
11
|
+
Twitter::Base.new('your email', 'your password').update('watching veronica mars')
|
12
|
+
|
13
|
+
# or you can use post
|
14
|
+
Twitter::Base.new('your email', 'your password').post('post works too')
|
15
|
+
|
16
|
+
puts "Public Timeline", "=" * 50
|
17
|
+
Twitter::Base.new('your email', 'your password').timeline(:public).each do |s|
|
18
|
+
puts s.text, s.user.name
|
19
|
+
puts
|
20
|
+
end
|
21
|
+
|
22
|
+
puts '', "Friends Timeline", "=" * 50
|
23
|
+
Twitter::Base.new('your email', 'your password').timeline.each do |s|
|
24
|
+
puts s.text, s.user.name
|
25
|
+
puts
|
26
|
+
end
|
27
|
+
|
28
|
+
puts '', "Friends", "=" * 50
|
29
|
+
Twitter::Base.new('your email', 'your password').friends.each do |u|
|
30
|
+
puts u.name, u.status.text
|
31
|
+
puts
|
32
|
+
end
|
33
|
+
|
34
|
+
puts '', "Followers", "=" * 50
|
35
|
+
Twitter::Base.new('your email', 'your password').followers.each do |u|
|
36
|
+
puts u.name, u.status.text
|
37
|
+
puts
|
38
|
+
end
|
39
|
+
|
40
|
+
== Search Examples
|
41
|
+
|
42
|
+
Twitter::Search.new('httparty').each { |r| puts r.inspect }
|
43
|
+
Twitter::Search.new('httparty').from('jnunemaker').each { |r| puts r.inspect }
|
44
|
+
Twitter::Search.new.from('jnunemaker').to('oaknd1').each { |r| puts r.inspect }
|
45
|
+
|
46
|
+
|
47
|
+
== Command Line Use
|
48
|
+
|
49
|
+
Note: If you want to use twitter from the command line be sure that sqlite3 and the sqlite3-ruby gem are installed. I removed the sqlite3-ruby gem as a dependency because you shouldn't need that to just use the API wrapper. Eventually I'll move the CLI interface into another gem.
|
50
|
+
|
51
|
+
$ twitter
|
52
|
+
|
53
|
+
Will give you a list of all the commands. You can get the help for each command by running twitter [command] -h.
|
54
|
+
|
55
|
+
The first thing you'll want to do is install the database so your account(s) can be stored.
|
56
|
+
|
57
|
+
$ twitter install
|
58
|
+
|
59
|
+
You can always uninstall twitter like this:
|
60
|
+
|
61
|
+
$ twitter uninstall
|
62
|
+
|
63
|
+
Once the twitter database is installed and migrated, you can add accounts like this:
|
64
|
+
|
65
|
+
$ twitter add
|
66
|
+
Add New Account:
|
67
|
+
Username: jnunemaker
|
68
|
+
Password (won't be displayed):
|
69
|
+
Account added.
|
70
|
+
|
71
|
+
You can also list all the accounts you've added.
|
72
|
+
|
73
|
+
$ twitter list
|
74
|
+
Account List
|
75
|
+
* jnunemaker
|
76
|
+
snitch_test
|
77
|
+
|
78
|
+
The * means denotes the account that will be used when posting, befriending, defriending, following, leaving or viewing a timeline.
|
79
|
+
|
80
|
+
To post using the account marked with the *, simply type the following:
|
81
|
+
|
82
|
+
$ twitter post "releasing my new twitter gem"
|
83
|
+
|
84
|
+
That is about it. You can do pretty much anything that you can do with twitter from the command line interface.
|
data/Rakefile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
ProjectName = 'twitter'
|
2
|
+
WebsitePath = "jnunemaker@rubyforge.org:/var/www/gforge-projects/#{ProjectName}"
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'rake'
|
6
|
+
require 'echoe'
|
7
|
+
require 'spec/rake/spectask'
|
8
|
+
require "lib/#{ProjectName}/version"
|
9
|
+
|
10
|
+
Echoe.new(ProjectName, Twitter::Version) do |p|
|
11
|
+
p.description = "a command line interface for twitter, also a library which wraps the twitter api"
|
12
|
+
p.url = "http://#{ProjectName}.rubyforge.org"
|
13
|
+
p.author = "John Nunemaker"
|
14
|
+
p.email = "nunemaker@gmail.com"
|
15
|
+
p.extra_deps = [['hpricot', '>= 0.6'], ['activesupport', '>= 2.1'], ['httparty', '>= 0.2.4']]
|
16
|
+
p.need_tar_gz = false
|
17
|
+
p.docs_host = WebsitePath
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'Upload website files to rubyforge'
|
21
|
+
task :website do
|
22
|
+
sh %{rsync -av website/ #{WebsitePath}}
|
23
|
+
Rake::Task['website_docs'].invoke
|
24
|
+
end
|
25
|
+
|
26
|
+
task :website_docs do
|
27
|
+
Rake::Task['redocs'].invoke
|
28
|
+
sh %{rsync -av doc/ #{WebsitePath}/docs}
|
29
|
+
end
|
30
|
+
|
31
|
+
desc 'Preps the gem for a new release'
|
32
|
+
task :prepare do
|
33
|
+
%w[manifest build_gemspec].each do |task|
|
34
|
+
Rake::Task[task].invoke
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
Rake::Task[:default].prerequisites.clear
|
39
|
+
task :default => :spec
|
40
|
+
Spec::Rake::SpecTask.new do |t|
|
41
|
+
t.spec_files = FileList["spec/**/*_spec.rb"]
|
42
|
+
end
|
data/bin/twitter
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# if we have stdin, let's prepend it to the message for post
|
4
|
+
if ARGV[0] && ARGV[0] == 'post' && !STDIN.tty?
|
5
|
+
ARGV[1] = "#{STDIN.read}#{ARGV[1]}"
|
6
|
+
end
|
7
|
+
|
8
|
+
# if we have stdin, let's prepend it to the message for d
|
9
|
+
if ARGV[0] && ARGV[0] == 'd' && !STDIN.tty?
|
10
|
+
ARGV[2] = "#{STDIN.read}#{ARGV[2]}"
|
11
|
+
end
|
12
|
+
|
13
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'twitter'))
|
14
|
+
require 'twitter/cli'
|
data/examples/blocks.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
|
3
|
+
config = YAML::load(open(ENV['HOME'] + '/.twitter'))
|
4
|
+
|
5
|
+
twitter = Twitter::Base.new(config['email'], config['password'])
|
6
|
+
|
7
|
+
puts 'BLOCK CREATE'
|
8
|
+
puts twitter.block('project_rockne').name
|
9
|
+
puts
|
10
|
+
puts
|
11
|
+
|
12
|
+
puts 'BLOCK DESTROY'
|
13
|
+
puts twitter.block('project_rockne').name
|
14
|
+
puts
|
15
|
+
puts
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'activesupport'
|
3
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
|
4
|
+
config = YAML::load(open(ENV['HOME'] + '/.twitter'))
|
5
|
+
|
6
|
+
twitter = Twitter::Base.new(config['email'], config['password'])
|
7
|
+
|
8
|
+
puts 'SINCE'
|
9
|
+
twitter.direct_messages(:since => Time.now - 5.day).each do |s|
|
10
|
+
puts "- #{s.id} #{s.text}"
|
11
|
+
end
|
12
|
+
puts
|
13
|
+
puts
|
14
|
+
|
15
|
+
# puts 'SINCE_ID'
|
16
|
+
# twitter.direct_messages(:since_id => 33505386).each do |s|
|
17
|
+
# puts "- #{s.text}"
|
18
|
+
# end
|
19
|
+
# puts
|
20
|
+
# puts
|
21
|
+
#
|
22
|
+
# puts 'PAGE'
|
23
|
+
# twitter.direct_messages(:page => 1).each do |s|
|
24
|
+
# puts "- #{s.text}"
|
25
|
+
# end
|
26
|
+
# puts
|
27
|
+
# puts
|
28
|
+
|
29
|
+
# puts twitter.destroy_direct_message(34489057).inspect
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
|
3
|
+
config = YAML::load(open(ENV['HOME'] + '/.twitter'))
|
4
|
+
|
5
|
+
twitter = Twitter::Base.new(config['email'], config['password'])
|
6
|
+
|
7
|
+
puts 'CREATE'
|
8
|
+
puts twitter.create_favorite(865416114).text
|
9
|
+
puts
|
10
|
+
puts
|
11
|
+
|
12
|
+
puts 'FAVORITES'
|
13
|
+
twitter.favorites.each { |f| puts f.text }
|
14
|
+
puts
|
15
|
+
puts
|
16
|
+
|
17
|
+
puts 'DESTROY'
|
18
|
+
puts twitter.destroy_favorite(865416114).text
|
19
|
+
puts
|
20
|
+
puts
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
|
3
|
+
config = YAML::load(open(ENV['HOME'] + '/.twitter'))
|
4
|
+
|
5
|
+
twitter = Twitter::Base.new(config['email'], config['password'])
|
6
|
+
|
7
|
+
puts "FRIENDS"
|
8
|
+
twitter.friends.each { |f| puts f.name }
|
9
|
+
puts
|
10
|
+
puts
|
11
|
+
|
12
|
+
puts "FRIENDS FOR"
|
13
|
+
twitter.friends_for('orderedlist', :lite => true).each { |f| puts f.name }
|
14
|
+
puts
|
15
|
+
puts
|
16
|
+
|
17
|
+
puts "FOLLOWERS"
|
18
|
+
twitter.followers(:lite => true).each { |f| puts f.name }
|
19
|
+
puts
|
20
|
+
puts
|
21
|
+
|
22
|
+
puts "FOLLOWERS FOR"
|
23
|
+
twitter.followers_for('orderedlist', :lite => true).each { |f| puts f.name }
|
24
|
+
puts
|
25
|
+
puts
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
|
3
|
+
config = YAML::load(open(ENV['HOME'] + '/.twitter'))
|
4
|
+
|
5
|
+
twitter = Twitter::Base.new(config['email'], config['password'])
|
6
|
+
|
7
|
+
puts twitter.create_friendship('orderedlist').name
|
8
|
+
puts twitter.follow('orderedlist').name
|
9
|
+
puts twitter.leave('orderedlist').name
|
10
|
+
puts twitter.destroy_friendship('orderedlist').name
|
11
|
+
|
12
|
+
puts twitter.friendship_exists?('jnunemaker', 'orderedlist').inspect
|
13
|
+
puts twitter.friendship_exists?('jnunemaker', 'ze').inspect
|
@@ -0,0 +1,7 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
|
3
|
+
config = YAML::load(open(ENV['HOME'] + '/.twitter'))
|
4
|
+
|
5
|
+
identica = Twitter::Base.new(config['email'], config['password'], :api_host => 'identi.ca/api')
|
6
|
+
|
7
|
+
identica.timeline(:public).each { |s| puts s.text, s.user.name, '' }
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
|
3
|
+
config = YAML::load(open(ENV['HOME'] + '/.twitter'))
|
4
|
+
|
5
|
+
twitter = Twitter::Base.new(config['email'], config['password'])
|
6
|
+
|
7
|
+
puts twitter.update_location('Hollywood, CA').location
|
8
|
+
puts twitter.update_delivery_device('none')
|
data/examples/posting.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
|
3
|
+
config = YAML::load(open(ENV['HOME'] + '/.twitter'))
|
4
|
+
|
5
|
+
twitter = Twitter::Base.new(config['email'], config['password'])
|
6
|
+
puts twitter.post("This is a test from the example file").inspect
|
7
|
+
|
8
|
+
# sending a direct message
|
9
|
+
# puts twitter.d('jnunemaker', 'this is a test').inspect
|
data/examples/replies.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'activesupport'
|
3
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
|
4
|
+
config = YAML::load(open(ENV['HOME'] + '/.twitter'))
|
5
|
+
|
6
|
+
twitter = Twitter::Base.new(config['email'], config['password'])
|
7
|
+
|
8
|
+
puts 'SINCE'
|
9
|
+
twitter.replies(:since => Time.now - 5.day).each do |s|
|
10
|
+
puts "- #{s.text}"
|
11
|
+
end
|
12
|
+
puts
|
13
|
+
puts
|
14
|
+
|
15
|
+
puts 'SINCE_ID'
|
16
|
+
twitter.replies(:since_id => 863081345).each do |s|
|
17
|
+
puts "- #{s.text}"
|
18
|
+
end
|
19
|
+
puts
|
20
|
+
puts
|
21
|
+
|
22
|
+
puts 'PAGE'
|
23
|
+
twitter.replies(:page => 1).each do |s|
|
24
|
+
puts "- #{s.text}"
|
25
|
+
end
|
26
|
+
puts
|
27
|
+
puts
|
data/examples/search.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
|
3
|
+
|
4
|
+
Twitter::Search.new('httparty').each { |r| puts r.inspect,'' }
|
5
|
+
Twitter::Search.new('httparty').page(2).each { |r| puts r.inspect, '' }
|
6
|
+
|
7
|
+
# search = Twitter::Search.new
|
8
|
+
# search.from('jnunemaker').to('oaknd1').each { |r| puts r.inspect, '' }
|
9
|
+
# pp search.result
|
10
|
+
# search.clear
|
11
|
+
|
12
|
+
# search.from('jnunemaker').to('oaknd1').since(814529437).containing('milk').each { |r| puts r.inspect, '' }
|
13
|
+
# search.clear
|
14
|
+
#
|
15
|
+
# search.geocode('40.757929', '-73.985506', '50mi').containing('holland').each { |r| puts r.inspect, '' }
|
16
|
+
# search.clear
|
17
|
+
|
18
|
+
# pp search.from('jnunemaker').fetch()
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'activesupport'
|
3
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
|
4
|
+
config = YAML::load(open(ENV['HOME'] + '/.twitter'))
|
5
|
+
|
6
|
+
twitter = Twitter::Base.new(config['email'], config['password'])
|
7
|
+
|
8
|
+
puts 'SINCE'
|
9
|
+
twitter.sent_messages(:since => Time.now - 5.day).each do |s|
|
10
|
+
puts "- #{s.text}"
|
11
|
+
end
|
12
|
+
puts
|
13
|
+
puts
|
14
|
+
|
15
|
+
puts 'SINCE_ID'
|
16
|
+
twitter.sent_messages(:since_id => 33505386).each do |s|
|
17
|
+
puts "- #{s.text}"
|
18
|
+
end
|
19
|
+
puts
|
20
|
+
puts
|
21
|
+
|
22
|
+
puts 'PAGE'
|
23
|
+
twitter.sent_messages(:page => 1).each do |s|
|
24
|
+
puts "- #{s.text}"
|
25
|
+
end
|
26
|
+
puts
|
27
|
+
puts
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'activesupport'
|
3
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
|
4
|
+
config = YAML::load(open(ENV['HOME'] + '/.twitter'))
|
5
|
+
|
6
|
+
twitter = Twitter::Base.new(config['email'], config['password'])
|
7
|
+
|
8
|
+
puts 'SINCE'
|
9
|
+
twitter.timeline(:user, :since => Time.now - 1.day).each do |s|
|
10
|
+
puts "- #{s.text}"
|
11
|
+
end
|
12
|
+
puts
|
13
|
+
puts
|
14
|
+
|
15
|
+
puts 'SINCE_ID'
|
16
|
+
twitter.timeline(:user, :since_id => 865547074).each do |s|
|
17
|
+
puts "- #{s.text}"
|
18
|
+
end
|
19
|
+
puts
|
20
|
+
puts
|
21
|
+
|
22
|
+
puts 'COUNT'
|
23
|
+
twitter.timeline(:user, :count => 1).each do |s|
|
24
|
+
puts "- #{s.text}"
|
25
|
+
end
|
26
|
+
puts
|
27
|
+
puts
|
28
|
+
|
29
|
+
puts 'PAGE'
|
30
|
+
twitter.timeline(:user, :page => 1).each do |s|
|
31
|
+
puts "- #{s.text}"
|
32
|
+
end
|
33
|
+
puts
|
34
|
+
puts
|
data/examples/twitter.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
|
3
|
+
config = YAML::load(open(ENV['HOME'] + '/.twitter'))
|
4
|
+
|
5
|
+
puts "Public Timeline", "=" * 50
|
6
|
+
Twitter::Base.new(config['email'], config['password']).timeline(:public).each do |s|
|
7
|
+
puts s.text, s.user.name
|
8
|
+
puts
|
9
|
+
end
|
10
|
+
|
11
|
+
puts '', "Friends Timeline", "=" * 50
|
12
|
+
Twitter::Base.new(config['email'], config['password']).timeline.each do |s|
|
13
|
+
puts s.text, s.user.name
|
14
|
+
puts
|
15
|
+
end
|
16
|
+
|
17
|
+
puts '', "Friends", "=" * 50
|
18
|
+
Twitter::Base.new(config['email'], config['password']).friends.each do |u|
|
19
|
+
puts u.name, u.status.text
|
20
|
+
puts
|
21
|
+
end
|
22
|
+
|
23
|
+
puts '', "Followers", "=" * 50
|
24
|
+
Twitter::Base.new(config['email'], config['password']).followers.each do |u|
|
25
|
+
puts u.name, u.status.text
|
26
|
+
puts
|
27
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
|
3
|
+
config = YAML::load(open(ENV['HOME'] + '/.twitter'))
|
4
|
+
|
5
|
+
twitter = Twitter::Base.new(config['email'], config['password'])
|
6
|
+
|
7
|
+
puts twitter.verify_credentials
|
8
|
+
|
9
|
+
begin
|
10
|
+
Twitter::Base.new('asdf', 'foobar').verify_credentials
|
11
|
+
rescue => error
|
12
|
+
puts error.message
|
13
|
+
end
|