Skip to content

Instantly share code, notes, and snippets.

@ssig33
Created October 12, 2010 15:33
Show Gist options
  • Save ssig33/622379 to your computer and use it in GitHub Desktop.
Save ssig33/622379 to your computer and use it in GitHub Desktop.
EMAIL = ""
PASS = ""
CLIENT_ID = ""
def get_token
agent = Mechanize.new
page = agent.get URI.parse "http://www.facebook.com/"
form = page.forms.first
form.email = EMAIL
form.pass = PASS
res = agent.submit(form)
page = agent.get URI.parse "https://graph.facebook.com/oauth/authorize?client_id=#{CLIENT_ID}&redirect_uri=http://www.facebook.com/connect/login_success.html&type=user_agent&display=popup&scope=publish_stream"
#最初にこの URL にブラウザからアクセスして allow しといてね
#scope offline_access の方が便利かも?????
page.search("script").last.children.first.to_s.split('"')[1].split("=")[1].split("&").first
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment