އިންޑެކްސްއަށް ޕޭޖެއް އިތުރުކުރުން/އަޕްޑޭޓް ކުރުން:
PUT https://dhivehi.mv/api/cse/{yourdomain.mv}
//json data must be encoded
//indexing will begin after 5 minutes of posting
{
"apikey": "Your API key",
//page absolute url
"url": "http://yourdomain.mv/page1.html",
//page created time
"time": "2016-01-01 23:00:10",
//DV
"title": "Title of page",
//striped html - DV
"body": "text content",
//EN or DV - optional [multiple can be defined]
"category": "news, world, sports, technology, lifestyle, religious, etc",
//DV - optional
"keywords": "keyword1 keyword2 keyword3",
//optional
"images": ["image_url_1","image_url_2","image_url_3"]
}
Response:
{ //json data
"status": "ok",
"code": 200
}
|
//sample php code
$data = array();
$data['apikey'] = "Your API key";
$data['url'] = "http://yourdomain.mv/page1.html";
$data['time'] = "2016-01-01 23:00:10";
$data['title'] = "Title of page";
$data['body'] = "text content";
$data['category'] = "news, world";
$data['keywords'] = "keyword1 keyword2 keyword3";
$data['images'] = array("image_url_1","image_url_2","image_url_3");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://dhivehi.mv/api/cse/yourdomain.mv");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
print_r($response);
//sample js code
//JS CODE IS ONLY FOR TESTING & SHOULD NOT BE USED IN PRODUCTION
json = {
'apikey': 'Your API key',
'url': 'http://yourdomain.mv/page1.html',
'time': '2016-01-01 23:00:10',
'title': 'Title of page',
'body': 'text content',
'category': 'news, world',
'keywords': 'keyword1 keyword2 keyword3',
'images': [
'image_url_1',
'image_url_2',
'image_url_3'
]
};
$.ajax({
url: 'https://dhivehi.mv/api/cse/yourdomain.mv',
dataType: 'json',
method: "PUT",
data: JSON.stringify(json),
success: function (data) {
console.log(data);
}
})
|
އިންޑެކްސްއިން ޕޭޖެއް ފޮހެލުން:
DELETE https://dhivehi.mv/api/cse/{yourdomain.mv}
//json data must be encoded
{
"apikey": "Your API key",
"url": "http://yourdomain.mv/page1.html"
}
Response:
//json data
{
"status": "ok",
"code": 200
}
|
//sample php code
$data = array();
$data['apikey'] = "Your API key";
$data['url'] = "http://yourdomain.mv/page1.html";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://dhivehi.mv/api/cse/yourdomain.mv");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
print_r($response);
//sample js code
//JS CODE IS ONLY FOR TESTING & SHOULD NOT BE USED IN PRODUCTION
json = {
'apikey': 'Your API key',
'url': 'http://yourdomain.mv/page1.html',
};
$.ajax({
url: 'https://dhivehi.mv/api/cse/yourdomain.mv',
dataType: 'json',
method: "DELETE",
data: JSON.stringify(json),
success: function (data) {
console.log(data);
}
})
|
ސާރޗު ކުރެއްވުން:
GET https://dhivehi.mv/api/cse/ {yourdomain.mv}?apikey= {your api key}&q= {search text}&p= {page}&r= {results per page}
//parameters
"apikey": "Your API key",
"q": "search text", //not more than 10 words
"p": 1, //optional, default page is 1
"r": 10 //optional, results per page, default is 10, max: 20
Response:
//json data
{
"status": "ok",
"code": 200,
"total": 2,
"page": 1,
"results": [{
"url": "http://yourdomain.mv/page1.html",
"time": "2016-01-01 01:00:10",
"title": "Title 1",
"body": "text content", //trimmed text content
"images": ["image_url_1", "image_url_2", "image_url_3"]
}
,
{
"url": "http://yourdomain.mv/page2.html",
"time": "2016-01-01 22:00:10",
"title": "Title 2",
"body": "text content", //trimmed text content
"images": ["image_url_1", "image_url_2"]
}
]
}
|
//sample php code
$data = array();
$data['apikey'] = "Your API key";
$data['q'] = "search text";
$data['p'] = 1;
$data['r'] = 10;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://dhivehi.mv/api/cse/yourdomain.mv?".
http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
print_r($response);
//sample js code
//JS CODE IS ONLY FOR TESTING & SHOULD NOT BE USED IN PRODUCTION
$.ajax({
url: 'https://dhivehi.mv/api/cse/yourdomain.mv',
dataType: 'json',
method: 'GET',
data: {
'apikey': 'Your API key',
'q': 'search text',
'p': 1
},
success: function (data) {
console.log(data);
}
});
|
|