foreach ($fd_list as $fd) { $_SESSION['fd_user_info'][$fd->getId()] = $fd->getInfo($access_token); } 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;
<?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);