From 2c78510e91c3afe6491726372b16fe12862d5f0f Mon Sep 17 00:00:00 2001 From: Sonu Malik Date: Mon, 30 Aug 2021 12:10:12 +0530 Subject: [PATCH 1/2] Update imagetyperz-api.js functionality for base64 image --- lib/imagetyperz-api.js | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/lib/imagetyperz-api.js b/lib/imagetyperz-api.js index 66bd22c..030c639 100644 --- a/lib/imagetyperz-api.js +++ b/lib/imagetyperz-api.js @@ -71,6 +71,47 @@ exports.account_balance = function () { return deferred.promise; }; +exports.submit_image_base64 = function (img_data, optional_parameters) { + var deferred = Q.defer(); + var data = {}, url = undefined, img_data = undefined; + if (_username && _password) { + // legacy auth + data['username'] = _username; + data['password'] = _password; + url = endpoints.CAPTCHA_ENDPOINT; + } + else { + data['token'] = _access_key; + } + + // add rest of params + data['action'] = 'UPLOADCAPTCHA'; + data['file'] = img_data; + + // optional parameters + let optional_keys = Object.keys(optional_parameters); + // check if any given + if(optional_keys.length > 0){ + let i = 0; + for(i = 0; i < optional_keys.length; i++){ + let key = optional_keys[i]; + data[key] = optional_parameters[key]; + } + } + + // check for affiliate id + if (_affiliate_id) data['affiliateid'] = _affiliate_id; + + // submit to server + requests.post(url, data).then(function (resp) { + var s = resp.split('|'); + deferred.resolve(s[0]); + }).catch(function (err) { + deferred.reject(err); + }); + return deferred.promise; +}; + exports.submit_image = function (image, optional_parameters) { var deferred = Q.defer(); var data = {}, url = undefined, img_data = undefined; From 9c9cd13bf536039d6edadb98bc10e802203e9fb1 Mon Sep 17 00:00:00 2001 From: Sonu Malik Date: Mon, 30 Aug 2021 12:12:28 +0530 Subject: [PATCH 2/2] Update imagetyperz-api.js added url --- lib/imagetyperz-api.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/imagetyperz-api.js b/lib/imagetyperz-api.js index 030c639..864e552 100644 --- a/lib/imagetyperz-api.js +++ b/lib/imagetyperz-api.js @@ -73,7 +73,7 @@ exports.account_balance = function () { exports.submit_image_base64 = function (img_data, optional_parameters) { var deferred = Q.defer(); - var data = {}, url = undefined, img_data = undefined; + var data = {}, url = undefined; if (_username && _password) { // legacy auth data['username'] = _username; @@ -81,6 +81,7 @@ exports.submit_image_base64 = function (img_data, optional_parameters) { url = endpoints.CAPTCHA_ENDPOINT; } else { + url = endpoints.CAPTCHA_ENDPOINT_CONTENT_TOKEN; data['token'] = _access_key; }