Skip to content

Instantly share code, notes, and snippets.

@neonichu
Created January 30, 2012 01:24
Show Gist options
  • Save neonichu/1701800 to your computer and use it in GitHub Desktop.
Save neonichu/1701800 to your computer and use it in GitHub Desktop.
Automatically post to your Google+ account from the commandline.
#!/usr/bin/env ruby
##### Automatically post to your Google+ account from the commandline.
##### (C) 2012 Boris Buegling <boris@icculus.org>
require 'rubygems'
require 'mechanize'
## Use Windows Mobile user agent to get Basic Mobile HTML
agent = Mechanize.new
agent.user_agent = 'HTC_Mega Opera/9.5 (Microsoft Windows; PPC Opera Mobi /17753; U; es-ES)'
## Login to Google account
page = agent.get('https://accounts.google.com/ServiceLoginAuth')
form = page.forms.first
form.Email = '<<<username>>>'
form.Passwd = '<<<password>>>'
agent.submit form
## Click on 'Post'
page = agent.get('https://plus.google.com')
post = page.links_with(:text => 'Post').first
## Write the post
page = agent.click post
form = page.forms.first
form.newcontent = '<<<text to post>>>'
post = form.button_with(:value => 'Post')
form.submit post
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment