diff --git a/src/providers/sources/showbox/sendRequest.ts b/src/providers/sources/showbox/sendRequest.ts index 7ea9024..248fddd 100644 --- a/src/providers/sources/showbox/sendRequest.ts +++ b/src/providers/sources/showbox/sendRequest.ts @@ -2,6 +2,7 @@ import CryptoJS from 'crypto-js'; import { customAlphabet } from 'nanoid'; import type { ScrapeContext } from '@/utils/context'; +import { createSearchParams } from '@/utils/params'; import { apiUrls, appId, appKey, key } from './common'; import { encrypt, getVerify } from './crypto'; @@ -34,13 +35,14 @@ export const sendRequest = async (ctx: ScrapeContext, data: object, altApi = fal }); const base64body = btoa(body); - const formatted = new URLSearchParams(); - formatted.append('data', base64body); - formatted.append('appid', '27'); - formatted.append('platform', 'android'); - formatted.append('version', '129'); - formatted.append('medium', 'Website'); - formatted.append('token', randomId(32)); + const formatted = { + data: base64body, + appid: '27', + platform: 'android', + version: '129', + medium: 'Website', + token: randomId(32), + }; const requestUrl = altApi ? apiUrls[1] : apiUrls[0]; @@ -51,7 +53,7 @@ export const sendRequest = async (ctx: ScrapeContext, data: object, altApi = fal 'Content-Type': 'application/x-www-form-urlencoded', 'User-Agent': 'okhttp/3.2.0', }, - body: formatted, + body: createSearchParams(formatted), }); return JSON.parse(response); }; diff --git a/src/utils/params.ts b/src/utils/params.ts new file mode 100644 index 0000000..ea2149f --- /dev/null +++ b/src/utils/params.ts @@ -0,0 +1,5 @@ +export function createSearchParams(params: { [key: string]: string | number }): string { + return Object.entries(params) + .map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`) + .join('&'); +}