Class: Ubiquitously::StumbleUpon::Post
- Inherits:
-
Ubiquitously::Service::Post
- Object
- Base
- Ubiquitously::Service::Post
- Ubiquitously::StumbleUpon::Post
- Defined in:
- lib/ubiquitously/services/stumble_upon.rb
Instance Attribute Summary
Attributes inherited from Ubiquitously::Service::Post
#captcha, #categories, #description, #downvotes, #extension, #format, #image, #kind, #must_be_unique, #privacy, #rating, #remote, #service_id, #service_url, #slug, #source, #source_url, #state, #status, #tags, #title, #token, #upvotes, #url, #user, #vote
Instance Method Summary collapse
Methods inherited from Ubiquitously::Service::Post
Methods included from Loggable::Post
Methods included from Restful::Post
Methods included from Postable::Post
Methods included from Ownable::Post
Methods inherited from Base
Methods included from SubclassableCallbacks
Constructor Details
This class inherits a constructor from Ubiquitously::Service::Post
Instance Method Details
permalink #create ⇒ Object
[View source]
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/ubiquitously/services/stumble_upon.rb', line 18 def create page = agent.get("http://www.stumbleupon.com/favorites/") action = "http://www.stumbleupon.com/ajax/edit/comment" form = page.forms.detect do |form| !form.form_node.css("textarea#review").first.blank? end headers = { "X-Requested-With" => "XMLHttpRequest", "Accept" => "application/json, text/javascript, */*" } # get key properties key = page.parser.css("div#wrapperContent").first["class"] var = page.parser.css("li.listLi var").first comment_id = var["id"].blank? ? 0 : var["id"] public_id = var["class"].blank? ? "" : var["class"] # post to hidden api params = { "url" => token[:url], "title" => token[:title], "review" => token[:description], "tags" => token[:tags], "token" => key, "sticky_post" => "0", "publicid" => "", "syndicate_fb" =>"syndicate_fb", "syndicate_tw" => "syndicate_tw", "commentid" => 0, "new_post" => 1, "blog_post" => 0, "keep_date" => 0 } form.action = action form.method = "POST" params.each do |k, v| form[k] = v end page = form.submit(nil, headers) true end |