Skip to content

Instantly share code, notes, and snippets.

@Jabbslad
Created June 29, 2009 16:49
Show Gist options
  • Save Jabbslad/137695 to your computer and use it in GitHub Desktop.
Save Jabbslad/137695 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'mechanize'
class Session
FRIENDS_URL = "http://live.xbox.com/en-US/profile/Friends.aspx"
attr_reader :agent
def initialize
@agent = WWW::Mechanize.new
agent.user_agent_alias='Windows IE 7'
end
def sign_in(username, password)
page = agent.get(FRIENDS_URL)
login = page.form_with(:name => "f1")
login['login'] = username
login['passwd'] = password
login['LoginOptions'] = 2
page = agent.submit(login)
page = agent.submit(page.form_with(:name => "fmHF"))
end
def sign_out
initialize
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment