{"id":1598,"date":"2026-01-08T14:04:19","date_gmt":"2026-01-08T13:04:19","guid":{"rendered":"https:\/\/fiches-especes.simonpotier.fr\/?page_id=1598"},"modified":"2026-01-08T14:04:42","modified_gmt":"2026-01-08T13:04:42","slug":"test-api","status":"publish","type":"page","link":"https:\/\/spes.anivise.fr\/index.php\/test-api\/","title":{"rendered":"test api"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-page\" data-elementor-id=\"1598\" class=\"elementor elementor-1598\" data-elementor-post-type=\"page\">\n\t\t\t\t<div class=\"elementor-element elementor-element-6040b90 e-flex e-con-boxed parallax_section_no qode_elementor_container_no e-con e-parent\" data-id=\"6040b90\" data-element_type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-3a9233f elementor-widget elementor-widget-html\" data-id=\"3a9233f\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t  <div style=\"border:1px solid #ddd;padding:14px;border-radius:8px;max-width:720px\">\n    <strong>Fiches API Test<\/strong>\n    <div style=\"margin-top:10px;display:flex;gap:10px;flex-wrap:wrap\">\n      <button type=\"button\" id=\"fiches-btn-whoami-auth\">Tester whoami-auth<\/button>\n      <button type=\"button\" id=\"fiches-btn-secure\">Tester secure-test<\/button>\n      <button type=\"button\" id=\"fiches-btn-data\">Tester data premium<\/button>\n      <button type=\"button\" id=\"fiches-btn-data-demo\">Tester data d\u00e9mo<\/button>\n    <\/div>\n    <pre id=\"fiches-out\" style=\"margin-top:10px;white-space:pre-wrap;background:#fafafa;padding:10px;border-radius:6px;min-height:80px\"><\/pre>\n  <\/div>\n\n  <script>\n  (function(){\n    const out = document.getElementById('fiches-out');\n\n    const show = (title, payload) => {\n      out.textContent = title + \"\\\\n\\\\n\" + (typeof payload === 'string' ? payload : JSON.stringify(payload, null, 2));\n    };\n\n    const call = async (path) => {\n      if (!window.FICHES_API || !window.FICHES_API.restUrl) {\n        throw new Error(\"FICHES_API absent\");\n      }\n\n      const url = window.FICHES_API.restUrl.replace(\/\\\\\/$\/, '') + '\/' + path.replace(\/^\\\\\/\/,'');\n      const res = await fetch(url, {\n        method: 'GET',\n        credentials: 'same-origin',\n        headers: {\n          'Accept': 'application\/json',\n          'X-WP-Nonce': window.FICHES_API.nonce || ''\n        }\n      });\n\n      const raw = await res.text();\n      let json = null;\n\n      try {\n        json = JSON.parse(raw);\n      } catch(e) {}\n\n      return { status: res.status, raw, json };\n    };\n\n    document.getElementById('fiches-btn-whoami-auth').addEventListener('click', async () => {\n      try {\n        const r = await call('fiches\/v1\/whoami-auth');\n        show('HTTP ' + r.status, r.json || r.raw);\n      } catch(e) {\n        show('Erreur', String(e));\n      }\n    });\n\n    document.getElementById('fiches-btn-secure').addEventListener('click', async () => {\n      try {\n        const r = await call('fiches\/v1\/secure-test');\n        show('HTTP ' + r.status, r.json || r.raw);\n      } catch(e) {\n        show('Erreur', String(e));\n      }\n    });\n\n    document.getElementById('fiches-btn-data').addEventListener('click', async () => {\n      try {\n        const r = await call('fiches\/v1\/data?page=1&per_page=5');\n        show('HTTP ' + r.status, r.json || r.raw);\n      } catch(e) {\n        show('Erreur', String(e));\n      }\n    });\n\n    document.getElementById('fiches-btn-data-demo').addEventListener('click', async () => {\n      try {\n        const r = await call('fiches\/v1\/data-demo?page=1&per_page=5');\n        show('HTTP ' + r.status, r.json || r.raw);\n      } catch(e) {\n        show('Erreur', String(e));\n      }\n    });\n  })();\n  <\/script>\n  \r\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"Fiches API Test Tester whoami-auth Tester secure-test Tester data premium Tester data d\u00e9mo","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"pmpro_default_level":"","footnotes":""},"class_list":["post-1598","page","type-page","status-publish","hentry","pmpro-has-access"],"_links":{"self":[{"href":"https:\/\/spes.anivise.fr\/index.php\/wp-json\/wp\/v2\/pages\/1598","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/spes.anivise.fr\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/spes.anivise.fr\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/spes.anivise.fr\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/spes.anivise.fr\/index.php\/wp-json\/wp\/v2\/comments?post=1598"}],"version-history":[{"count":4,"href":"https:\/\/spes.anivise.fr\/index.php\/wp-json\/wp\/v2\/pages\/1598\/revisions"}],"predecessor-version":[{"id":1602,"href":"https:\/\/spes.anivise.fr\/index.php\/wp-json\/wp\/v2\/pages\/1598\/revisions\/1602"}],"wp:attachment":[{"href":"https:\/\/spes.anivise.fr\/index.php\/wp-json\/wp\/v2\/media?parent=1598"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}