Skip to content

Instantly share code, notes, and snippets.

@cia-rana
Created May 29, 2017 18:56
Show Gist options
  • Save cia-rana/54542259253667fd22115f9f41e36f86 to your computer and use it in GitHub Desktop.
Save cia-rana/54542259253667fd22115f9f41e36f86 to your computer and use it in GitHub Desktop.
To Get Pokémon Global Link Season Ranking
require "net/http"
require "uri"
require "json"
require "pp"
def post_pgl_ranking(season_id, battle_type, page_number)
url = "https://3ds.pokemon-gl.com/frontendApi/gbu/getSeasonRanking"
uri = URI.parse(url)
timestamp = Time.now.to_i
request = Net::HTTP::Post.new(uri.request_uri)
request["referer"] = "http://3ds.pokemon-gl.com/battle/"
request.set_form_data({
'languageId' => '1',
'seasonId' => season_id,
'page' => page_number,
'battleType' => battle_type,
'timezone' => 'JST',
'timeStamp' => timestamp
}, '&')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = (uri.scheme == "https")
response = http.request(request)
JSON.parse(response.entity).to_h
end
pp post_pgl_ranking(201, 1, 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment