CMXX - Include API authorization in index

This commit is contained in:
“VeLiTi”
2025-02-04 13:03:27 +01:00
parent fa09268cd8
commit 8201d7804b
2 changed files with 15 additions and 17 deletions

View File

@@ -6,17 +6,29 @@ $base_url = isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] === 'on' || $_SERVER[
$base_url .= '://' . rtrim($_SERVER['HTTP_HOST'], '/');
$base_url .= $_SERVER['SERVER_PORT'] == 80 || $_SERVER['SERVER_PORT'] == 443 || strpos($_SERVER['HTTP_HOST'], ':') !== false ? '' : ':' . $_SERVER['SERVER_PORT'];
$base_url .= '/' . ltrim(substr(str_replace('\\', '/', realpath(__DIR__)), strlen($_SERVER['DOCUMENT_ROOT'])), '/');
define('base_url', rtrim($base_url, '/') . '/');
// If somehow the above URL fails to resolve the correct URL, you can simply comment out the below line and manually specifiy the URL to the system.
// define('base_url', 'http://yourdomain.com/shoppingcart/');
// Initialize a new session
session_start();
// Include the configuration file, this contains settings you can change.
include './custom/settings/config.php';
// Include functions and connect to the database using PDO MySQL
include 'functions.php';
// Include translation file
include './custom/translations/translations_'.strtoupper(language_code).'.php';
//LOGIN TO API
$data = json_encode(array("username" => "paul@veliti.nl", "password" => "test1234"), JSON_UNESCAPED_UNICODE);
$responses = ioAPIv2('/v2/authorization', $data,'');
//Decode Payload
if (!empty($responses)){$responses = json_decode($responses,true);}else{$responses = '400';}
$clientsecret = $responses['token'];
//IMAGE URL
$img_url = substr(api_url, 0, -8);
// Connect to MySQL database
$pdo = pdo_connect_mysql();
// Output error variable