@@ -274,6 +274,14 @@ export interface paramsKeyCaptcha {
274274 proxytype ?: string
275275}
276276
277+ export interface paramsTencent {
278+ pageurl : string ,
279+ appId : string ,
280+ pingback ?: string ,
281+ proxy ?: string ,
282+ proxytype ?: string
283+ }
284+
277285/**
278286 * An object containing properties of the captcha solution.
279287 * @typedef {Object } CaptchaAnswer
@@ -1712,6 +1720,66 @@ public async keyCaptcha(params: paramsKeyCaptcha): Promise<CaptchaAnswer> {
17121720 }
17131721}
17141722
1723+ /**
1724+ * ### Solves a Tencent.
1725+ *
1726+ * Use this method to solve Tencent captcha. Returns a token.
1727+ * [Read more about Tencent](https://2captcha.com/2captcha-api#tencent).
1728+ *
1729+ * @param {{ pageurl, appId, pingback, proxy, proxytype } } params Parameters for solving Tencent as an object.
1730+ * @param {string } params.pageurl The URL where the captcha is located.
1731+ * @param {string } params.appId The value of `appId` parameter in the website source code.
1732+ * @param {string } [params.pingback] Optional param. URL for pingback (callback) response when captcha is solved.
1733+ * @param {string } [params.proxy] Optional param. Proxy to use while solving the captcha. Format: `login:password@123.123.123.123:3128`.
1734+ * @param {string } [params.proxytype] Optional param. Type of your proxy: `HTTP`, `HTTPS`, `SOCKS4`, `SOCKS5`.
1735+ *
1736+ * @returns {Promise<CaptchaAnswer> } The result from the solve.
1737+ * @throws APIError
1738+ *
1739+ * @example
1740+ * solver.tencent({
1741+ * pageurl: "https://mysite.com/page/with/tencent",
1742+ * appId: "189956587"
1743+ * })
1744+ * .then((res) => {
1745+ * console.log(res);
1746+ * })
1747+ * .catch((err) => {
1748+ * console.log(err);
1749+ * })
1750+ */
1751+ public async tencent ( params : paramsTencent ) : Promise < CaptchaAnswer > {
1752+ params = await renameParams ( params )
1753+ checkCaptchaParams ( params , "tencent" )
1754+
1755+ const payload = {
1756+ ...params ,
1757+ method : "tencent" ,
1758+ ...this . defaultPayload ,
1759+ }
1760+
1761+ const URL = this . in
1762+ const response = await fetch ( URL , {
1763+ body : JSON . stringify ( payload ) ,
1764+ method : "post" ,
1765+ headers : { 'Content-Type' : 'application/json' }
1766+ } )
1767+ const result = await response . text ( )
1768+
1769+ let data ;
1770+ try {
1771+ data = JSON . parse ( result )
1772+ } catch {
1773+ throw new APIError ( result )
1774+ }
1775+
1776+ if ( data . status == 1 ) {
1777+ return this . pollResponse ( data . request )
1778+ } else {
1779+ throw new APIError ( data . request )
1780+ }
1781+ }
1782+
17151783 /**
17161784 * Reports a captcha as correctly solved.
17171785 *
0 commit comments