`
jsntghf
  • 浏览: 2479637 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

验证Google账号和密码

阅读更多

 

  require 'net/https'
  def google_login(username, password)
    url = URI.parse('https://www.google.com/accounts/ClientLogin')
    http = Net::HTTP.new(url.host, url.port)
    http.use_ssl = true
    res = http.start do |http|
      req = Net::HTTP::Post.new(url.path)
      req.set_form_data({'Email' => username, 'Passwd' => password, 'service' => 'xapi', 'source' => 'rails-plugins'},'&')
      http.request(req)
    end
    case res
    when Net::HTTPSuccess
      true
    else
      false
    end
  end

  if google_login('jsntghf@gmail.com','password')
    puts "success"
  else
    puts "failed"
  end

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics