Created
October 12, 2010 15:33
-
-
Save ssig33/622379 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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