ini_set ('display_errors', 1); ini_set ('display_startup_errors', 1); error_reporting (E_ALL); $path ='wp-content/themes/storefront-child-theme-master/'; require_once $path .'/dompdf/autoload.inc.php'; require_once __DIR__ . '/wp-load.php'; use Dompdf\Dompdf; use Dompdf\Options; use Dompdf\CanvasFactory; // instantiate and use the dompdf class setlocale( LC_TIME, "fr_FR", "French" ); // Récupérer l'ID depuis l'URL $id = filter_input( INPUT_GET, 'id', FILTER_VALIDATE_INT ); if ( !$id ) { die( "Paramètre 'id' manquant ou invalide." ); } // Identifiants de connexion $credentials = [ "id" => "APP-API-AVANTIS", "secret" => "Uf7xXAHK92qOSqTXrudpahKE", "code" => "10381" ]; // Étape 1 : Obtenir le token via POST $ch = curl_init( 'https://api.glowinthecloud.com/login' ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $ch, CURLOPT_POST, true ); curl_setopt( $ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', 'Accept: application/json' ] ); curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $credentials ) ); $response = curl_exec( $ch ); $error = curl_error( $ch ); curl_close( $ch ); if ( $error ) { die( "Erreur cURL (login) : $error" ); } $json = json_decode( $response, true ); if ( json_last_error() !== JSON_ERROR_NONE ) { die( "Erreur JSON : " . json_last_error_msg() ); } if ( !isset( $json[ 'token' ] ) ) { die( "Token manquant dans la réponse :\n" . print_r( $json, true ) ); } $token = $json[ 'token' ]; // Étape 2 : Appeler l'API avec le token et l'ID $curl = curl_init(); curl_setopt_array( $curl, array( CURLOPT_URL => "https://api.glowinthecloud.com/public-request/$id", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'Authorization: ' . $token, 'Accept: application/json' // 'Cookie: PHPSESSID=...' // ← Retire sauf si l’API le demande ), ) ); $output = curl_exec( $curl ); $error2 = curl_error( $curl ); curl_close( $curl ); if ( $error2 ) { die( "Erreur cURL (public-request) : $error2" ); } $array = json_decode( $output, true ); if ( json_last_error() !== JSON_ERROR_NONE ) { die( "Erreur JSON (public-request) : " . json_last_error_msg() ); } //var_dump($array); $id = $array['data']['id']; $facility_name = $wpdb->get_var( $wpdb->prepare( "SELECT facility_name FROM `wp_jobs` WHERE id_job = %d", $id ) ); //echo $facility_name; $texte_establishments = $wpdb->get_var( $wpdb->prepare( "SELECT texte FROM `wp_jobs_establishments` WHERE establishments = %s", $facility_name ) ); $title = $array['data']['fr_title']; $description = $array['data']['fr_description']; $cat_name = $array['data']["sectors"][0]["description_fr"]; $facility_name = $array['data']['city'] .', ' . $array['data']['province']; $cat_horaire = $array['data']["job_types"][0]["description_fr"]; $ref_number = $array['data']['id']; $icons = [ 1 => 'activites_de_mobilisation_01.php', 2 => 'allocation_pour_cellulaire_01.php', 3 => 'allocation_pour_achat_outils_01.php', 4 => 'alternance_entre_presentiel_et_teletravail_01.php', 5 => 'assurances_collectives_avec_participation_financiere_de_employeur_01.php', 6 => 'bonification_technique_au_rendement_01.php', 7 => 'comite_sante_mieux-etre_01.php', 8 => 'conges_personnels_01.php', 9 => 'conges_personnels_et_maladies_01.php', 10 => 'formation_remuneree_DEP_en_vente_01.php', 11 => 'plages_horaires_variees_01.php', 12 => 'possibilites_avancement_01.php', 14 => 'prime_de_fin_etudes_01.php', 15 => 'prime_de_garde_01.php', 16 => 'prime_de_referencement_de_coequipier_01.php', 17 => 'prime_de_soir_et_fin_de_semaine_01.php', 18 => 'programme_aide_aux_employes_01.php', 19 => 'programme_de_reconnaissance_01.php', 20 => 'regime_de_retraite_01.php', 21 => 'remuneration_a_la_commission_avec_un_salaire_de_base_01.php', 22 => 'remuneration_variable_01.php', 23 => 'service_de_telemedecine_24-7_pour_toi_et_ta_famille_01.php', 24 => 'ententes_corporatives_01.php', 25 => 'rabais_coequipiers_en_succursales_avantis_01.php', 26 => 'regime_investissement_cooperatif_01.php', 27 => 'teletravail_01.php', 28 => 'vehicule_fourni_01.php', 29 => 'vetements_de_travail_payes_01.php', 30 => 'formations_completes_et_remunerees_01.php' ]; // Trier les bénéfices usort($array['data']['benefits'], function ($a, $b) { return strcoll($a['description_fr'], $b['description_fr']); }); // --- Capture du HTML dans $avantage --- ob_start(); ?>