Get 5 cat pictures
var param = {"hash":"cat", "show": 5 }
$.ajax({
url: "/api/content/",
method: "GET",
data:param
}).done(function( json ) {
console.log(json);
});
Another example
//Get 5 content elements from specific user
var param = {"user":"chuck noris", "show": 5 }
//Get 5 content elements from specific id
var param = {"id":"123", "show": 5 }
Simple example, just text
var text="new content";
var api_key="";
$.ajax({
url: '/api/content/',
data: { "content": text, "api_key" : api_key},
type: 'POST',
success: function(result) {
console.log(result);
}
});
Website and Text
var text="content with website";
var url="https://fsfe.org/";
var metadata = {"type":"www", "url":url}
var api_key="";
$.ajax({
url: '/api/content/',
data: { "content": text, "metadata": JSON.stringify(metadata), "api_key" : api_key},
type: 'POST',
success: function(result) {
console.log(result);
}
});
Text and Image
var text="new content with image";
var image="http://u.dasmerkendienie.com/03f99096092a63bfba23486718f7690fba666e658311d671a72d5962af4b7ba16daa9104a038730fad3e3690cea9db5288413ff3f9ed9c9fe1ab166fa93dce2c.gif";
var metadata = {"type":"img", "url":image}
var api_key="";
$.ajax({
url: '/api/content/',
data: { "content": text, "metadata": JSON.stringify(metadata), "api_key" : api_key},
type: 'POST',
success: function(result) {
console.log(result);
}
});
var id="123"; //id of content element you wish to update;
var text="new content";
var api_key="";
$.ajax({
url: '/api/content/'+id,
data: { "content": text, "api_key" : api_key},
type: 'PUT',
success: function(result) {
console.log(result);
}
});
var id="123"; //id of content element you wish to delete;
var api_key="";
$.ajax({
url: '/api/content/'+id,
param: {"api_key":api_key},
type: 'DELETE',
success: function(result) {
if(result.status=="deleted"){
console.log("element deleted");
}
}
});
Get Comment
Post Comment