<?php require_once __DIR__ . "/../init.php"; try { $data = file_get_contents('php://input'); $data = json_decode($data, true); if (!$data) { throw new Exception("Empty data !"); } foreach (array('description', 'email', 'name', 'data', 'urlCallback') as $key) { if (empty($data[$key])) { throw new Exception("{$key} est obligatoire !"); } } $buttonSQL = new ButtonSQL($sqlQuery); $buttonDataSQL = new ButtonDataSQL($sqlQuery); $id_button = $buttonSQL->createButton($data['name'], $data['description'], $data['email'], $data['urlCallback']); foreach ($data['data'] as $id_fd => $fd_data) { foreach ($fd_data as $id_data) { $buttonDataSQL->addData($id_button, $id_fd, $id_data); } } } catch (Exception $e) { $result = array('code' => '500', 'response' => array(), 'message' => $e->getMessage()); header("HTTP/1.1 500 Internal Server Error"); echo json_encode($result); exit; } $result = array('code' => '200', 'response' => array('url_btn' => $url_button . "?id_btn={$id_button}"), 'message' => "Bouton créé avec succès."); echo json_encode($result);
} header("Location: test.php"); exit; } $info = array(); $info['identite_pivot'] = array('name' => 'Identité', 'data' => array()); $identite_pivot = array('birthcountry' => 'Pays de naissance', 'birthdate' => 'Date de naissane', "given_name" => 'Prénom', 'family_name' => 'Nom', 'gender' => 'Sexe', 'preferred_username' => "Nom d'usage"); foreach ($identite_pivot as $data_id => $data_libelle) { if (empty($_SESSION['user_info'][$data_id])) { continue; } $info['identite_pivot']['data'][$data_id] = array($data_libelle, $_SESSION['user_info'][$data_id]); } $buttonSQL = new ButtonSQL($sqlQuery); $info_button = $buttonSQL->getInfo($id_btn); $buttonDataSQL = new ButtonDataSQL($sqlQuery); $fd_id_list = $buttonDataSQL->getIdFDList($id_btn); foreach ($fd_id_list as $fd_id) { if (empty($fd_list[$fd_id])) { continue; } $fd = $fd_list[$fd_id]; $fd_all_data = $fd->getInfo($access_token); $info[$fd_id] = array('name' => $fd->getName(), 'data' => array()); $data_list = $buttonDataSQL->getFdData($id_btn, $fd_id); $provided_info = $fd->getProvidedInfo(); foreach ($fd_all_data as $data_id => $data_value) { if (!in_array($data_id, $data_list)) { continue; } $info[$fd_id]['data'][$data_id] = array($provided_info[$data_id], $fd_all_data[$data_id]);
<?php require_once __DIR__ . "/../init.php"; try { if (empty($_GET['id_btn'])) { throw new Exception("Pas de id_btn"); } $id_btn = $_GET['id_btn']; $buttonDataSQL = new ButtonDataSQL($sqlQuery); $fd_id_list = $buttonDataSQL->getIdFDList($id_btn); $fournisseurDonneesSet = new FournisseurDonneesSet(); $fd_list = $fournisseurDonneesSet->getAllFD($franceConnect); $scope = array(); foreach ($fd_id_list as $fd_id) { if (empty($fd_list[$fd_id])) { continue; } $scope[$fd_list[$fd_id]->getScope()] = true; } $scope = array_keys($scope); $franceConnect->authenticationRedirect($url_callback, $scope, $id_btn); } catch (Exception $e) { header("HTTP/1.1 500 Internal Server Error"); echo "Une erreur est survenue : " . $e->getMessage(); }