/*
Theme Name: Assurena Child
Author: StylusThemes
Author URI: https://stylusthemes.com/
Description: -
Version: 1.1.0
Template: assurena
Text Domain:  assurena-child
*/
add_action('init', function() {
    if (isset($_GET['test_grawe_token'])) {
        $url = 'https://prodajatest.grawe.rs/apitest/api/Authentication/GenerateToken';
        $data = json_encode([
            "Username" => "wsTestGrawe",
            "Password" => "TEstGrawe.9545w9tr98"
        ]);

        $response = wp_remote_post($url, [
            'headers' => ['Content-Type' => 'application/json'],
            'body' => $data,
            'method' => 'POST',
            'timeout' => 15,
        ]);

        echo "<pre>";
        if (is_wp_error($response)) {
            echo "Greška: " . $response->get_error_message();
        } else {
            print_r(json_decode(wp_remote_retrieve_body($response), true));
        }
        echo "</pre>";
        exit;
    }
});