Update API

j 2024-06-22 08:22:59 +00:00
parent 75b6118b9f
commit 73ff9f871d

44
API.md

@ -61,23 +61,37 @@ var_dump($result);
<html>
<head>
<script>
function pandora_api(action, data, callback) {
var url = 'http://archive.arabdigitalexpression.org/api/';
var xhr = new XMLHttpRequest();
xhr.addEventListener('load', function (evt) {
var data = JSON.parse(evt.target.responseText);
callback(data);
});
var formData = new FormData();
formData.append('action', action);
formData.append('data', JSON.stringify(data));
xhr.open('POST', url);
xhr.send(formData);
async function api(action, data) {
const url = "https://pad.ma/api/"
var response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
action: action,
data: data
})
})
return await response.json();
}
pandora_api('find', {query: ....}, function(result) {
console.log(result)
});
api('find', {
query: {
conditions: [
{key: 'title', operator: '=', value: 'A Day'}
]
},
keys: ['id', 'title', 'summary'],
range: [0, 10]
}).then(result => {
result.data.items.forEach(item => {
const div = document.createElement("div")
div.innerHTML = `<h1><a href="https://pad.ma/${item.id}">${item.title}</a></h1><p>${item.summary}</p>`
document.body.appendChild(div)
})
})
</script>
</head>
<body>