findout:api
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Prochaine révision | Révision précédente | ||
| findout:api [2023/08/09 19:03] – created 85.169.126.26 | findout:api [2023/10/13 10:03] (Version actuelle) – admin | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| - | **hierarchie** | + | base : /api |
| - | <code> | + | * GET /code --> Swagger |
| - | classes/<classname>/<classname>.php | + | * GET /code/< code> --> Le contenu du code (Utilisateur, |
| - | classes/<classname>/traits/<traitname>.php (<traitname> = <classname><traitpart> pour éviter les doublons (à challenger) | + | * DELETE /code/< code> --> Supprime l' |
| - | </ | + | |
| + | * <del>PATCH /code/< code> --> Ne devrait pas être possible, ni nécessaire</ | ||
| + | | ||
| - | chaque classe inclut | + | * GET /heading --> Swagger |
| - | <code> | + | * GET /heading/<heading> --> Restitue les éléments intrinsèques de la rubrique |
| - | set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__)); | + | * PUT /heading/ --> Créer une nouvelle rubrique |
| - | </code> | + | * PATCH / |
| + | * DELETE / | ||
| + | * < | ||
| - | **apiPath.php** | + | |
| + | | ||
| + | | ||
| + | | ||
| + | * DELETE / | ||
| + | * < | ||
| - | <file> | + | * GET /sower --> Liste des utilisateurs (pour admin seulement) |
| - | <?php | + | * GET /sower/<sower> --> Elément liés à l' |
| + | * PUT /sower --> Créer une nouvel utilisateur (quid de la création quand c'est à partir d'un réseau social) | ||
| + | * PATCH /sower/<sower> --> modifier les paramètres utilisateur | ||
| + | * DELETE / | ||
| + | * POST / | ||
| + | * POST / | ||
| + | * POST / | ||
| + | * POST / | ||
| - | $sApiPaths = '[ | + | * GET /sower/< |
| - | { " | + | |
| - | { " | + | |
| - | { " | + | |
| - | { " | + | |
| - | | + | |
| - | { " | + | |
| - | { " | + | |
| - | { " | + | |
| - | ]' | + | |
| - | spl_autoload_register(function($className) { | + | * GET /sower/< |
| - | $fileName = stream_resolve_include_path(' | + | |
| - | if ($fileName !== false) { | + | |
| - | include $fileName; | + | |
| - | } | + | |
| - | }); | + | |
| - | spl_autoload_register(function($traitName) { | + | |
| - | $fileName = stream_resolve_include_path(' | + | |
| - | if ($fileName !== false) { | + | |
| - | include $fileName; | + | |
| - | } | + | |
| - | }); | + | |
| - | function apiPathMatch | + | * GET / |
| - | | + | * GET /sower/< |
| - | | + | * POST / |
| - | $sFirst = $aPath [ 0 ] ; | + | |
| - | $sMethod = $method ; | + | |
| - | $aCompare = sortPaths () ; | + | Optionnel / plus tard |
| - | | + | * GET / |
| - | if ( $method != $aValue [ 'method' | + | * PATCH /sower/<sower>/ |
| - | if ( $sFirst != $aValue [ ' | + | |
| - | if ( $iParts | + | |
| - | if ( $iParts > $aValue [ ' | + | |
| - | if ( $iParts == 1 ) { | + | * PUT / |
| - | doThings ( $aValue [ 'first' | + | * PATCH / |
| - | | + | * DELETE / |
| - | } | + | |
| - | $iCount = 0 ; | + | * GET /sower/< |
| - | foreach ( explode ( '/', $aValue [ ' | + | * PUT /like --> recevoir un like concernant l'application |
| - | | + | * POST / |
| - | if ( preg_match ( '/\$.*/', $sPath ) ) continue ; | + | |
| - | if ( $sPath != $aPath [ $iKey2 ] ) break ; | + | |
| - | } | + | |
| - | if ( $iCount == $iParts | + | |
| - | doThings ( $aValue [ 'first' ], $aValue [ ' | + | |
| - | return ; | + | |
| - | } | + | |
| - | } | + | |
| - | echo "No match" ; | + | |
| - | } | + | |
| - | function sortPaths () { | + | * POST /report/bug --> rapporter un dysfonctionnement |
| - | | + | * POST / |
| - | $aPaths = json_decode ( $sApiPaths, true ) ; | + | Pour les admins |
| - | + | * GET / | |
| - | foreach ( $aPaths as $iKey => $aPath ) { | + | * GET /system/ |
| - | | + | * PATCH /system/option/< |
| - | $sLocalGo = $aPath [' | + | * GET /system/ |
| - | $aLocalPath = explode ('/', $sLocalPath) ; | + | * PUT / |
| - | $iLocalPart = count ( $aLocalPath ) ; | + | * DELETE / |
| - | $sLocalFirst = $aLocalPath [0] ; | + | * GET /system/ban -> liste des utilisateurs à qui on a retiré le droit de se connecter |
| - | $sLocalMethod = $aPath [ ' | + | * PUT /system/ban/< |
| - | + | * DELETE / | |
| - | $aLocalResult [ $iKey ] [ ' | + | * GET /system/ |
| - | $aLocalResult [ $iKey ] [ ' | + | |
| - | $aLocalResult [ $iKey ] [ ' | + | |
| - | $aLocalResult [ $iKey ] [ ' | + | |
| - | $aLocalResult [ $iKey ] [ ' | + | |
| - | + | ||
| - | $aSort1 [ $iKey ] = $sLocalFirst ; | + | |
| - | $aSort2 [ $iKey ] = $iLocalPart ; | + | |
| - | } | + | |
| - | + | ||
| - | array_multisort($aSort1, | + | |
| - | + | ||
| - | return $aLocalResult ; | + | |
| - | } | + | |
| - | + | ||
| - | function doThings( $class, $method, $path) | + | |
| - | { | + | |
| - | $o = new $class () ; | + | |
| - | $a = explode ( ';', | + | |
| - | $m = $a [ 0 ] ; | + | |
| - | $p = explode ( ',', | + | |
| - | $pa = explode ( '/', $path ) ; | + | |
| - | $pl = [] ; | + | |
| - | foreach ( $p as $k => $pn ) { | + | |
| - | echo "avec le param : " . $pa [ $pn ] . " | + | |
| - | $pl [] = $pa [ $pn ] ; | + | |
| - | } | + | |
| - | + | ||
| - | $o -> {$m} ( $pl ) ; | + | |
| - | } | + | |
| - | + | ||
| - | apiPathMatch ( ' | + | |
| - | + | ||
| - | ?> | + | |
| - | </file> | + | |
| - | + | ||
| - | **Classe | + | |
| - | * classes/obj2.php * | + | |
| - | + | ||
| - | <file> | + | |
| - | <?php | + | |
| - | + | ||
| - | set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__)); | + | |
| - | + | ||
| - | class obj1 { | + | |
| - | use obj1Get ; | + | |
| - | use obj1GetAll ; | + | |
| - | use obj1Patch ; | + | |
| - | + | ||
| - | private $text; | + | |
| - | + | ||
| - | function __construct () { | + | |
| - | $this -> text = 'Je suis OBJ1' ; | + | |
| - | } | + | |
| - | + | ||
| - | public function getText () { | + | |
| - | return ( $this -> text ) ; | + | |
| - | } | + | |
| - | } | + | |
| - | + | ||
| - | </file> | + | |
| - | + | ||
| - | **Trait : obj2GetDetail** | + | |
| - | * classes/obj2/traits/obj2GetDetail.php * | + | |
| - | * paramètre : tableau de valeurs * | + | |
| - | + | ||
| - | <file> | + | |
| - | <?php | + | |
| - | + | ||
| - | trait obj2GetDetail { | + | |
| - | function getDetail ( $p ) { | + | |
| - | echo $this -> text () . " | + | |
| - | echo "- dans getDetails" | + | |
| - | echo "- params : " . $p [0] . ", " . $p [1] . " | + | |
| - | } | + | |
| - | } | + | |
| - | + | ||
| - | </file> | + | |
| + | (*)s' | ||
findout/api.1691600597.txt.gz · Dernière modification : 2023/08/09 19:03 de 85.169.126.26 · Actuellement bloqué par : 192.168.0.100,216.73.216.57