Class: Googletastic::Apps

Inherits:
Base
  • Object
show all
Defined in:
lib/googletastic/apps.rb

Constant Summary

Constants included from Mixins::Namespaces

Mixins::Namespaces::NAMESPACES

Instance Attribute Summary

Attributes inherited from Base

#acl, #attachment_path, #created_at, #etag, #head, #id, #keep_raw, #raw, #response, #synced_with, #updated_at

Attributes included from Mixins::Attributes

#attributes

Class Method Summary collapse

Methods inherited from Base

client_class, #initialize, #to_xml

Methods included from Mixins::Pagination

included

Methods included from Mixins::Finders

included

Methods included from Mixins::Parsing

included

Methods included from Mixins::Requesting

included

Methods included from Mixins::Attributes

#attribute_names, #has_attribute?, #inspect

Methods included from Mixins::Namespaces

included

Constructor Details

This class inherits a constructor from Googletastic::Base

Class Method Details

.create(options = {}) ⇒ Object

follow_meta_refresh for FORMS!!! might have to save cookiejar between requests as captcha is presented domain, first_name, last_name, email, phone, country, username, password, password_confirmation



12
13
14
15
16
17
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
# File 'lib/googletastic/apps.rb', line 12

def create(options = {})
  # precaptcha and postcaptcha
  agent = WWW::Mechanize.new
  page = agent.get(new_url)
  # fill out domain name (must already have)
  form = page.forms_with("domainEntry").first
  form.radiobuttons.first.check
  form.fields_with("existingDomain").first.value = options[:domain]
  second_page = agent.submit(form)
  # fill out profile
  form = second_page.forms.first
  form.firstName = options[:first_name]
  form.lastName = options[:last_name]
  form.email = options[:email]
  form.phone = options[:phone]
  #form.jobTitle = ""
  #form.orgName = ""
  # default value is "US"
  form.country = options[:country] || "US"
  # form.orgType = ""
  # form.orgSize
  # DO YOU AGREE???
  form.checkboxes_with("domainAdminCheck").first.check
  # third page must be filled out within about a minute it seems
  third_page = agent.submit(form)
  form = last_page.forms.first
  # sample CAPTCHA URL (or "format=audio")
  # form.captchaToken
  # https://www.google.com/a/cpanel/captcha?format=image&captchaToken=crazy-token
  form.captchaAnswer = "progshi"
  form.newUserName = options[:username]
  # minimum 6 chars
  form.fields_with("newPassword.alpha").first.value = options[:password]
  form.fields_with("newPassword.beta").first.value = options[:password_confirmation]
  last_page = agent.submit(form)

  # now you have your account
  form = last_page.forms_with(:action => "VerifyDomainOwnership").first
  form.radiobuttons_with(:value => "htmlVer").first.check

  verify_page = agent.submit(form)
  form = verify_page.forms_with(:action => "VerifyDomainOwnership") # or "id => 'verificationPages'"
  # upload file "googlehostedservice.html" with special text, and let google know it's okay
  special_text = verify_page.parser.xpath("//span[@class='callout']").first.text
  # upload to http://tinker.heroku.com/googlehostedservice.html
  apps_home = agent.submit(form)
end

.new_urlObject



5
6
7
# File 'lib/googletastic/apps.rb', line 5

def new_url
  "http://www.google.com/a/cpanel/domain/new"
end