app/controllers/api_controller.rb
# Use KGS's archives page to see if a username exists
Use KGS's archives page to see if a username exists
Use KGS ' s archives page to see if a username exists
def kgs_username
    url = "http://gokgs.com/gameArchives.jsp?user=#{params['username']}"
    document = Nokogiri::HTML.parse(
      URI.parse(url).open(
        read_timeout: GENERIC_READ_TIMEOUT,
        open_timeout: GENERIC_OPEN_TIMEOUT
      ).read
    )
    result = document.css("p")[0]
    if result.text.starts_with?("Sorry, there are no games")
      head :not_found
    else
      head :ok
    end
  end
def kgs_username url = "http://gokgs.com/gameArchives.jsp?user=#{params['username']}" document = Nokogiri :: HTML . parse ( URI . parse ( url ) . open ( read_timeout : GENERIC_READ_TIMEOUT , open_timeout : GENERIC_OPEN_TIMEOUT ) . read ) result = document . css ( "p" ) [ 0 ] if result . text . starts_with? ( "Sorry, there are no games" ) head :not_found else head :ok end end
Use KGS's archives page to see if a username exists
Use KGS ' s archives page to see if a username exists