ubiquitously 0.0.1.6 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +224 -19
- data/Rakefile +12 -4
- data/bin/u.me +4 -0
- data/lib/ubiquitously.rb +56 -7
- data/lib/ubiquitously/commands/base.rb +118 -0
- data/lib/ubiquitously/commands/post.rb +108 -0
- data/lib/ubiquitously/commands/user.rb +111 -0
- data/lib/ubiquitously/extensions/callbacks.rb +62 -0
- data/lib/ubiquitously/extensions/core.rb +88 -0
- data/lib/ubiquitously/extensions/mechanize.rb +35 -0
- data/lib/ubiquitously/models/base.rb +18 -0
- data/lib/ubiquitously/models/page.rb +28 -0
- data/lib/ubiquitously/models/post.rb +66 -0
- data/lib/ubiquitously/models/service.rb +1 -0
- data/lib/ubiquitously/models/service/account.rb +57 -0
- data/lib/ubiquitously/models/service/account/authorizable.rb +58 -0
- data/lib/ubiquitously/models/service/account/loggable.rb +50 -0
- data/lib/ubiquitously/models/service/account/restful.rb +21 -0
- data/lib/ubiquitously/models/service/post.rb +59 -0
- data/lib/ubiquitously/models/service/post/loggable.rb +64 -0
- data/lib/ubiquitously/models/service/post/ownable.rb +31 -0
- data/lib/ubiquitously/models/service/post/postable.rb +73 -0
- data/lib/ubiquitously/models/service/post/restful.rb +52 -0
- data/lib/ubiquitously/models/user.rb +128 -0
- data/lib/ubiquitously/services/blogger_den.rb +68 -0
- data/lib/ubiquitously/services/chetzit.rb +37 -0
- data/lib/ubiquitously/services/code_project.rb +21 -0
- data/lib/ubiquitously/services/delicious.rb +54 -0
- data/lib/ubiquitously/services/design_bump.rb +41 -0
- data/lib/ubiquitously/services/designgizer.rb +21 -0
- data/lib/ubiquitously/services/designr_fix.rb +21 -0
- data/lib/ubiquitously/services/digg.rb +151 -0
- data/lib/ubiquitously/services/digzign.rb +25 -0
- data/lib/ubiquitously/services/diigo.rb +68 -0
- data/lib/ubiquitously/services/dzone.rb +132 -0
- data/lib/ubiquitously/services/dzone_snippets.rb +39 -0
- data/lib/ubiquitously/services/facebook.rb +42 -0
- data/lib/ubiquitously/services/faves.rb +81 -0
- data/lib/ubiquitously/services/favshare.rb +78 -0
- data/lib/ubiquitously/services/flikode.rb +38 -0
- data/lib/ubiquitously/services/friendfeed.rb +21 -0
- data/lib/ubiquitously/services/gist.rb +52 -0
- data/lib/ubiquitously/services/google_buzz.rb +15 -0
- data/lib/ubiquitously/services/identica.rb +15 -0
- data/lib/ubiquitously/services/jump_tags.rb +21 -0
- data/lib/ubiquitously/services/kailoon.rb +27 -0
- data/lib/ubiquitously/services/meta_filter.rb +26 -0
- data/lib/ubiquitously/services/mixx.rb +94 -0
- data/lib/ubiquitously/services/mmo.rb +22 -0
- data/lib/ubiquitously/services/mvc_forge.rb +37 -0
- data/lib/ubiquitously/services/my_space.rb +25 -0
- data/lib/ubiquitously/services/nestdev.rb +36 -0
- data/lib/ubiquitously/services/newsvine.rb +76 -0
- data/lib/ubiquitously/services/pixel_groovy.rb +22 -0
- data/lib/ubiquitously/services/posterous.rb +24 -0
- data/lib/ubiquitously/services/programmers_heaven.rb +21 -0
- data/lib/ubiquitously/{propeller.rb → services/propeller.rb} +17 -26
- data/lib/ubiquitously/services/queness.rb +38 -0
- data/lib/ubiquitously/services/reddit.rb +62 -0
- data/lib/ubiquitously/services/scribd.rb +21 -0
- data/lib/ubiquitously/services/script_and_style.rb +23 -0
- data/lib/ubiquitously/services/sharebrain.rb +19 -0
- data/lib/ubiquitously/services/shoutwire.rb +34 -0
- data/lib/ubiquitously/services/slideshare.rb +70 -0
- data/lib/ubiquitously/services/smipple.rb +21 -0
- data/lib/ubiquitously/services/snipplr.rb +67 -0
- data/lib/ubiquitously/services/snipt.rb +49 -0
- data/lib/ubiquitously/services/sphinn.rb +24 -0
- data/lib/ubiquitously/services/stumble_upon.rb +67 -0
- data/lib/ubiquitously/services/stumpedia.rb +13 -0
- data/lib/ubiquitously/services/tumblr.rb +28 -0
- data/lib/ubiquitously/services/tweako.rb +53 -0
- data/lib/ubiquitously/services/twitter.rb +60 -0
- data/lib/ubiquitously/services/web_blend.rb +25 -0
- data/lib/ubiquitously/services/webdev5.rb +32 -0
- data/lib/ubiquitously/services/who_freelance.rb +21 -0
- data/lib/ubiquitously/services/wordtaps.rb +36 -0
- data/lib/ubiquitously/services/yahoo_buzz.rb +64 -0
- data/lib/ubiquitously/services/youblr.rb +15 -0
- data/lib/ubiquitously/services/zabox.rb +22 -0
- data/lib/ubiquitously/support/active_record.rb +25 -0
- data/lib/ubiquitously/support/storage.rb +71 -0
- data/test/config/cookies.yml +111 -0
- data/test/config/credentials.yml +7 -0
- data/test/config/secrets.yml +33 -0
- data/test/config/tokens.yml +30 -0
- data/test/meta.html +19 -0
- data/test/test_delicious.rb +37 -0
- data/test/test_digg.rb +57 -0
- data/test/test_dzone.rb +23 -18
- data/test/test_facebook.rb +40 -0
- data/test/test_faves.rb +18 -20
- data/test/test_helper.rb +8 -1
- data/test/test_newsvine.rb +3 -3
- data/test/test_page.rb +21 -0
- data/test/test_post.rb +55 -0
- data/test/test_propeller.rb +2 -2
- data/test/test_reddit.rb +26 -4
- data/test/test_stumble_upon.rb +23 -3
- data/test/test_twitter.rb +33 -0
- data/test/test_user.rb +22 -0
- metadata +199 -24
- data/lib/ext.rb +0 -37
- data/lib/ubiquitously/base.rb +0 -56
- data/lib/ubiquitously/dzone.rb +0 -111
- data/lib/ubiquitously/faves.rb +0 -43
- data/lib/ubiquitously/mister_wong.rb +0 -11
- data/lib/ubiquitously/mixins/resourceful.rb +0 -50
- data/lib/ubiquitously/mixx.rb +0 -66
- data/lib/ubiquitously/newsvine.rb +0 -54
- data/lib/ubiquitously/reddit.rb +0 -46
- data/lib/ubiquitously/sphinn.rb +0 -11
- data/lib/ubiquitously/stumble_upon.rb +0 -61
- data/test/config.yml +0 -18
@@ -0,0 +1,22 @@
|
|
1
|
+
# http://www.mmosocialnetwork.com/
|
2
|
+
module Ubiquitously
|
3
|
+
module Mmo
|
4
|
+
class Account < Ubiquitously::Service::Account
|
5
|
+
def login
|
6
|
+
page = agent.get("http://service.com/login")
|
7
|
+
form = page.form_with(:name => "loginform")
|
8
|
+
form["username"] = username
|
9
|
+
form["password"] = password
|
10
|
+
page = form.submit
|
11
|
+
|
12
|
+
authorized?(page.title =~ /Some title/i)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Post < Ubiquitously::Service::Post
|
17
|
+
def create
|
18
|
+
page = agent.get("")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Ubiquitously
|
2
|
+
module MvcForge
|
3
|
+
class Account < Ubiquitously::Service::Account
|
4
|
+
# raises Net::HTTPForbidden 403 if already logged in
|
5
|
+
def login
|
6
|
+
page = agent.get("http://mvcforge.com/user/login")
|
7
|
+
form = page.forms.detect { |form| form.form_node["id"] == "user-login" }
|
8
|
+
form["name"] = username
|
9
|
+
form["pass"] = password
|
10
|
+
|
11
|
+
page = form.submit
|
12
|
+
|
13
|
+
authorize!(page.parser.css(".messages.error").text.to_s !~ /unrecognized username or password/i)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class Post < Ubiquitously::Service::Post
|
18
|
+
def create
|
19
|
+
page = agent.get("http://mvcforge.com/submit")
|
20
|
+
form = page.form_with(:action => "/submit")
|
21
|
+
|
22
|
+
form["url"] = token[:url]
|
23
|
+
form["title"] = token[:title]
|
24
|
+
form["body"] = token[:description]
|
25
|
+
form["taxonomy[tags][3]"]
|
26
|
+
form.field_with(:name => "taxonomy[1]").options.each do |option|
|
27
|
+
option.select if option.value.to_s == "90"
|
28
|
+
end
|
29
|
+
form["op"] = "Submit"
|
30
|
+
|
31
|
+
page = form.submit(form.button_with(:value => "Submit"))
|
32
|
+
|
33
|
+
true
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Ubiquitously
|
2
|
+
module MySpace
|
3
|
+
class Account < Ubiquitously::Service::Account
|
4
|
+
def login
|
5
|
+
referer = "http://localhost:4567/"
|
6
|
+
url = MyspaceToken.authorize_url(referer)
|
7
|
+
page = agent.get(url, [], referer)
|
8
|
+
form = page.forms.detect { |form| form.form_node["id"] == "login_form" }
|
9
|
+
form["email"] = username
|
10
|
+
form["pass"] = password
|
11
|
+
page = form.submit
|
12
|
+
|
13
|
+
# do something with the oauth token, save it in the cookie?
|
14
|
+
|
15
|
+
authorized?(page.uri !~ /http:\/\/login\.facebook\.com\/login\.php/i)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class Post < Ubiquitously::Service::Post
|
20
|
+
def create
|
21
|
+
page = agent.get("")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Ubiquitously
|
2
|
+
module Nestdev
|
3
|
+
class Account < Ubiquitously::Service::Account
|
4
|
+
def login
|
5
|
+
page = agent.get("http://nestdev.com/wp-login.php")
|
6
|
+
form = page.form_with(:name => "loginform")
|
7
|
+
form["log"] = username
|
8
|
+
form["pwd"] = password
|
9
|
+
form.checkboxes.first.check
|
10
|
+
page = form.submit
|
11
|
+
|
12
|
+
authorize!(page.parser.css("#login_error").first.nil?)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Post < Ubiquitously::Service::Post
|
17
|
+
def create
|
18
|
+
page = agent.get("http://nestdev.com/")
|
19
|
+
form = page.form_with(:name => "new_post")
|
20
|
+
|
21
|
+
form["posttitle"] = token[:title]
|
22
|
+
form["posturl"] = token[:url]
|
23
|
+
form.field_with(:name => "post_category").options.each do |option|
|
24
|
+
option.select if option.value.to_s == "158"
|
25
|
+
end
|
26
|
+
# max length == 800
|
27
|
+
form["tags"] = token[:tags]
|
28
|
+
form["posttext"] = description
|
29
|
+
|
30
|
+
page = form.submit
|
31
|
+
|
32
|
+
true
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module Ubiquitously
|
2
|
+
module Newsvine
|
3
|
+
class Account < Ubiquitously::Service::Account
|
4
|
+
def login
|
5
|
+
page = agent.get("https://www.newsvine.com/_nv/accounts/login")
|
6
|
+
form = page.form_with(:action => "https://www.newsvine.com/_nv/api/accounts/login")
|
7
|
+
form["email"] = username
|
8
|
+
form["password"] = password
|
9
|
+
page = form.submit
|
10
|
+
|
11
|
+
authorize!(page.title !~ /Log in/i)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Post < Ubiquitously::Service::Post
|
16
|
+
def tokenize
|
17
|
+
super.merge(:tags => tags.taggify(" ", ", "))
|
18
|
+
end
|
19
|
+
|
20
|
+
def create
|
21
|
+
page = agent.get("http://www.newsvine.com/_tools/seed")
|
22
|
+
form = page.form_with(:action => "http://www.newsvine.com/_action/tools/saveLink")
|
23
|
+
|
24
|
+
form["url"] = token[:url]
|
25
|
+
form["headline"] = token[:title]
|
26
|
+
form.radiobuttons_with(:name => "newsType").each do |button|
|
27
|
+
button.check if button.value == "x"
|
28
|
+
end
|
29
|
+
form.field_with(:name => "categoryTag").options.each do |option|
|
30
|
+
option.select if option.value == "technology"
|
31
|
+
end
|
32
|
+
form["blurb"] = token[:description]
|
33
|
+
form["tags"] = token[:tags]
|
34
|
+
|
35
|
+
unless debug?
|
36
|
+
page = form.submit
|
37
|
+
end
|
38
|
+
|
39
|
+
true
|
40
|
+
end
|
41
|
+
|
42
|
+
class << self
|
43
|
+
def find(options = {})
|
44
|
+
records = []
|
45
|
+
user = options[:user]
|
46
|
+
user_url = "http://#{user.username_for(self)}.newsvine.com"
|
47
|
+
html = Nokogiri::HTML(open(user_url).read)
|
48
|
+
urls = url_permutations(options[:url])
|
49
|
+
|
50
|
+
html.css(".quickpost").each do |node|
|
51
|
+
title = node.css("h1").first.text rescue nil
|
52
|
+
url = node.css("a.external").first["href"] rescue nil
|
53
|
+
description = node.xpath("p").first.text rescue nil
|
54
|
+
service_url = node.css("h1 a").first["href"] rescue nil
|
55
|
+
tags = []
|
56
|
+
node.css(".tags a").each do |tag|
|
57
|
+
tags << tag.text
|
58
|
+
end
|
59
|
+
record = new(
|
60
|
+
:title => title,
|
61
|
+
:url => url,
|
62
|
+
:description => description,
|
63
|
+
:tags => tags,
|
64
|
+
:service_url => service_url,
|
65
|
+
:user => user
|
66
|
+
)
|
67
|
+
return record if urls.include?(record.url)
|
68
|
+
records << record
|
69
|
+
end
|
70
|
+
|
71
|
+
options[:url] ? nil : records
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# http://www.pixelgroovy.com/
|
2
|
+
module Ubiquitously
|
3
|
+
module PixelGroovy
|
4
|
+
class Account < Ubiquitously::Service::Account
|
5
|
+
def login
|
6
|
+
page = agent.get("http://service.com/login")
|
7
|
+
form = page.form_with(:name => "loginform")
|
8
|
+
form["username"] = username
|
9
|
+
form["password"] = password
|
10
|
+
page = form.submit
|
11
|
+
|
12
|
+
authorized?(page.title =~ /Some title/i)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Post < Ubiquitously::Service::Post
|
17
|
+
def create
|
18
|
+
page = agent.get("")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Ubiquitously
|
2
|
+
module Posterous
|
3
|
+
class Account < Ubiquitously::Service::Account
|
4
|
+
end
|
5
|
+
|
6
|
+
class Post < Ubiquitously::Service::Post
|
7
|
+
include HTTParty
|
8
|
+
base_uri 'http://posterous.com/api'
|
9
|
+
|
10
|
+
def create
|
11
|
+
self.class.post("/newpost", {
|
12
|
+
:query => {
|
13
|
+
:title => token[:title],
|
14
|
+
:body => token[:description],
|
15
|
+
:tags => token[:tags]
|
16
|
+
},
|
17
|
+
:basic_auth => @auth
|
18
|
+
})
|
19
|
+
|
20
|
+
true
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Ubiquitously
|
2
|
+
module ProgrammersHeaven
|
3
|
+
class Account < Ubiquitously::Service::Account
|
4
|
+
def login
|
5
|
+
page = agent.get("http://digzign.com/login")
|
6
|
+
form = page.form_with(:name => "loginform")
|
7
|
+
form["username"] = username
|
8
|
+
form["password"] = password
|
9
|
+
page = form.submit
|
10
|
+
|
11
|
+
authorize!(page.title =~ /Like Digg/i)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Post < Ubiquitously::Service::Post
|
16
|
+
def create
|
17
|
+
page = agent.get("")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,52 +1,43 @@
|
|
1
1
|
module Ubiquitously
|
2
2
|
module Propeller
|
3
|
-
class
|
3
|
+
class Account < Ubiquitously::Service::Account
|
4
4
|
def login
|
5
|
-
puts "LOGGING IN"
|
6
5
|
page = agent.get("http://www.propeller.com/signin/")
|
7
6
|
form = page.forms.detect {|form| form.form_node["class"] == "ajax-form"}
|
8
7
|
form["member_name"] = username
|
9
8
|
form["password"] = password
|
10
9
|
form["submit"] = "sign in" # require to get around the ajax
|
11
10
|
page = form.submit
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
unless @logged_in
|
16
|
-
raise AuthenticationError.new("Invalid username or password for #{service_name.titleize}")
|
17
|
-
end
|
18
|
-
|
19
|
-
@logged_in
|
11
|
+
|
12
|
+
authorize!((page.body !~ /Invalid member name or password/i) && (page.body !~ /ajax-form/))
|
20
13
|
end
|
21
14
|
end
|
22
15
|
|
23
|
-
class Post < Ubiquitously::
|
16
|
+
class Post < Ubiquitously::Service::Post
|
24
17
|
# title max == 150
|
25
|
-
|
18
|
+
def tokenize
|
19
|
+
super.merge(:tags => tags.taggify("_", " "))
|
20
|
+
end
|
26
21
|
|
27
|
-
def
|
28
|
-
return false unless valid?
|
29
|
-
|
30
|
-
user.login
|
31
|
-
|
22
|
+
def create
|
32
23
|
# url
|
33
24
|
page = agent.get("http://www.propeller.com/story/submit/")
|
34
25
|
form = page.forms.detect {|form| form.form_node["method"].downcase == "post"}
|
35
|
-
form["url"] = url
|
36
|
-
|
26
|
+
form["url"] = token[:url]
|
27
|
+
|
37
28
|
# details
|
38
29
|
# http://www.propeller.com/story/submit/content/
|
39
30
|
page = form.submit
|
40
31
|
form = page.forms.detect {|form| form.form_node["method"].downcase == "post"}
|
41
|
-
|
32
|
+
|
42
33
|
form.radiobuttons_with(:name => "title_multi").each do |button|
|
43
34
|
button.check if button.value == "-1"
|
44
35
|
end
|
45
36
|
|
46
|
-
form["title_multi_text"] = title
|
47
|
-
form["description"] = description
|
37
|
+
form["title_multi_text"] = token[:title]
|
38
|
+
form["description"] = token[:description]
|
48
39
|
# separate by space, multi words are underscored
|
49
|
-
form["user_tags"] = tags
|
40
|
+
form["user_tags"] = token[:tags]
|
50
41
|
|
51
42
|
form.radiobuttons_with(:name => "category").each do |button|
|
52
43
|
button.check if button.value.to_s == "18"
|
@@ -54,14 +45,14 @@ module Ubiquitously
|
|
54
45
|
|
55
46
|
# http://www.propeller.com/story/submit/preview/
|
56
47
|
page = form.submit
|
57
|
-
|
48
|
+
|
58
49
|
# approve
|
59
50
|
page.forms[1].submit
|
60
51
|
|
61
|
-
unless
|
52
|
+
unless debug?
|
62
53
|
page = form.submit
|
63
54
|
end
|
64
|
-
|
55
|
+
|
65
56
|
true
|
66
57
|
end
|
67
58
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Ubiquitously
|
2
|
+
module Queness
|
3
|
+
class Account < Ubiquitously::Service::Account
|
4
|
+
def login
|
5
|
+
page = agent.get("http://www.queness.com/")
|
6
|
+
form = page.form_with(:action => "http://www.queness.com/login.php")
|
7
|
+
form["login[username]"] = username
|
8
|
+
form["login[password]"] = password
|
9
|
+
form.checkboxes.first.check
|
10
|
+
page = form.submit
|
11
|
+
|
12
|
+
authorize!(page.parser.css(".error").text !~ /Incorrect/i)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Post < Ubiquitously::Service::Post
|
17
|
+
def create
|
18
|
+
page = agent.get("http://www.queness.com/post")
|
19
|
+
form = page.forms.detect { |form| !form.form_node.css(".postform").first.nil? }
|
20
|
+
|
21
|
+
form["form[title]"] = token[:title]
|
22
|
+
form["form[description]"] = token[:description]
|
23
|
+
form["form[url]"] = token[:url]
|
24
|
+
# 1-4 tags
|
25
|
+
form.checkboxes_with(:name => "tags[]").each do |box|
|
26
|
+
case box.value.to_s
|
27
|
+
when "1", "12", "11", "3"
|
28
|
+
box.check
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
page = form.submit
|
33
|
+
|
34
|
+
true
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Ubiquitously
|
2
|
+
module Reddit
|
3
|
+
class Account < Ubiquitously::Service::Account
|
4
|
+
def login
|
5
|
+
page = agent.get("http://www.reddit.com/")
|
6
|
+
form = page.form_with(:action => "http://www.reddit.com/post/login")
|
7
|
+
form["user"] = username
|
8
|
+
form["passwd"] = password
|
9
|
+
page = form.submit
|
10
|
+
|
11
|
+
authorize!(page.title !~ /login or register/i)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Post < Ubiquitously::Service::Post
|
16
|
+
def create
|
17
|
+
page = agent.get("http://www.reddit.com/submit?url=#{url}")
|
18
|
+
key = page.body.match(/modhash\:\s+'([^']+)'/)[1]
|
19
|
+
|
20
|
+
if page.parser.css(".infobar a").first.text =~ /submit it again/i
|
21
|
+
post = page.parser.css(".thing").first
|
22
|
+
id = post["class"].match(/id-(\w+)/)[1]
|
23
|
+
vh = post.css(".arrow.up").first["onclick"].match(/\((?:\s+)?['"](\w+)['"]/)[1]
|
24
|
+
post_site = page.body.match(/post_site:\s+['"]([^'"]+)['"]/)[1] rescue "javascript"
|
25
|
+
params = {
|
26
|
+
"id" => id,
|
27
|
+
"vh" => vh,
|
28
|
+
"dir" => 1,
|
29
|
+
"uh" => key,
|
30
|
+
"renderstyle" => "html",
|
31
|
+
"r" => post_site
|
32
|
+
}
|
33
|
+
|
34
|
+
# dir = 1, 0, or -1. “direction” of vote.
|
35
|
+
headers = {
|
36
|
+
"X-Requested-With" => "XMLHttpRequest",
|
37
|
+
"Accept" => "application/json, text/javascript, */*"
|
38
|
+
}
|
39
|
+
unless debug?
|
40
|
+
page = agent.post("http://www.reddit.com/api/vote", params, headers)
|
41
|
+
end
|
42
|
+
else
|
43
|
+
form = page.forms.detect {|form| form.form_node["id"] == "newlink"}
|
44
|
+
form["title"] = title
|
45
|
+
form["url"] = url
|
46
|
+
form["id"] = "#newlink"
|
47
|
+
form["uh"] = key
|
48
|
+
form["renderstyle"] = "html"
|
49
|
+
form["kind"] = "link"
|
50
|
+
|
51
|
+
form.action = "http://www.reddit.com/api/submit"
|
52
|
+
headers = {
|
53
|
+
"X-Requested-With" => "XMLHttpRequest"
|
54
|
+
}
|
55
|
+
unless debug?
|
56
|
+
page = form.submit(nil, headers)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|