-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.php
More file actions
35 lines (29 loc) · 734 Bytes
/
api.php
File metadata and controls
35 lines (29 loc) · 734 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
// check the header for the SECRET KEY
if ( 'POST' != $_SERVER['REQUEST_METHOD'] ) {
header('Allow: POST');
header('HTTP/1.1 405 Method Not Allowed');
header('Content-Type: text/plain');
exit;
}
$headers = apache_request_headers();
if ( ! array_key_exists('x-api-key', $headers)){
exit;
}
if ($headers['x-api-key'] != "extravagant-lemur"){
exit;
}
if (! array_key_exists('title', $_POST)){
exit;
}
$title = $_POST['title'];
$category = array_key_exists('category', $_POST) ? $_POST['category'] : "Recipies";
if (! array_key_exists('tags', $_POST)){
exit;
}
$tags = $_POST['tags'];
if (! array_key_exists('body', $_POST)){
exit;
}
$body = $_POST['body'];
echo $title . " " . $category . " " . $body;