Force legacy mode, instance level and user level

This commit is contained in:
Pablo Ferreiro 2022-03-11 20:50:11 +01:00
parent db3799c344
commit 73dd93420f
No known key found for this signature in database
GPG key ID: 41FBCE65B779FA24
9 changed files with 40 additions and 12 deletions

View file

@ -20,4 +20,10 @@ class SettingsController {
$url = Misc::url('/settings');
header("Location: {$url}");
}
static public function api() {
$_POST['legacy'] ?? Cookies::set('api-legacy', '1');
$url = Misc::url('/settings');
header("Location: {$url}");
}
}

View file

@ -30,8 +30,9 @@ class Misc {
/**
* Setup of TikTok Api wrapper
* @return \TikScraper\Api|\TikScraper\Legacy
*/
static public function api(): \TikScraper\Api {
static public function api() {
$options = [
'remote_signer' => self::env('SIGNER_URL', 'http://localhost:8080/signature'),
'use_test_endpoints' => self::env('USE_TEST_ENDPOINTS', false),
@ -75,8 +76,12 @@ class Misc {
break;
}
}
$api = new \TikScraper\Api($options, $cacheEngine);
return $api;
// Legacy mode
$legacy = self::env('FORCE_LEGACY', false); // Instance level
$_COOKIE['enable_legacy'] ?? $legacy = true; // User level
return $legacy === false ? new \TikScraper\Api($options, $cacheEngine) : new \TikScraper\Legacy($options, $cacheEngine);
}
/**