Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // examples for test:
- // resolver.url - https://pctest-live-front.playbattlegrounds.com
- // appUrl - https://pctest-live-front.playbattlegrounds.com/app/jk-pc-pc-1911-99/index-steam.jk-pc-pc-1911-99.html
- // rootUrl - (comes from appUrl page in script tag broConfiguration.uri) https://pctest-live-cfentry.playbattlegrounds.com/publicproxy
- // fetch is node-fetch
- const call = `${rootUrl}/${apiName}/${methodName}`;
- const agent = new http.Agent({
- keepAlive: true
- });
- // Don't know if CORS stuff is necessary, or if correct game user-agent is necessary (it seems to be for websocket api), referer and origin are necessary though
- const commonHeaders = {
- 'Referer': appUrl,
- 'Origin': resolver.url,
- 'User-Agent': 'Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.86 Safari/537.36',
- 'Access-Control-Request-Method': 'POST',
- 'Access-Control-Request-Headers': 'accept, origin, content-type',
- };
- const preflight = new fetch.Request(call, {
- method: 'options',
- agent,
- headers: Object.assign({}, commonHeaders, {
- 'Access-Control-Request-Method': 'POST',
- 'Access-Control-Request-Headers': 'Content-Type',
- }),
- });
- /** @type {fetch.Response} */
- const pfres = await fetch(preflight);
- // don't think invokerId matters for publicproxy api
- const body = [invokerId++,null,apiName,methodName,...parameters];
- const req = new fetch.Request(call, {
- method: 'post',
- agent,
- body: JSON.stringify(body),
- headers: Object.assign({}, commonHeaders),
- });
- const res = await fetch(req);
- if (res.ok) {
- const result = await res.json()
- // apiName: 'PublicProxyApi'
- // methodName: 'GetMissionSystemData'
- // parameters: ['steam.7656...'] (replace with steam id, no authentication so I don't think it matters whose it is)
- // apiName: 'PublicProxyApi'
- // methodName: 'GetBattlePassDatas'
- // parameters: ['steam.7656...'] (replace with steam id, no authentication so I don't think it matters whose it is)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement