-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpost.php
More file actions
58 lines (48 loc) · 1.73 KB
/
post.php
File metadata and controls
58 lines (48 loc) · 1.73 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
header('X-Frame-Options: DENY');
header('X-XSS-Protection: 1; mode=block');
header('X-Content-Type-Options: nosniff');
header('Strict-Transport-Security: max-age=63072000');
header('Content-type:application/json; charset=utf-8');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST');
header('Access-Control-Allow-Headers: Access-Control-Allow-Headers,Content-Type,Access-Control-Allow-Methods, Authorization, X-Requested-With');
header('X-Robots-Tag: noindex, nofollow', true);
include 'config.php';
if(isset($_GET['title']) && isset($_GET['html'])){
if(!empty($_GET['title']) && !empty($_GET['html'])){
$user_title = $_GET['title'];
$user_message = nl2br($_GET['html']);
$data = [
"posts" => [
[
"title" => $user_title,
"html" => $user_message,
"status" => $status,
"tags" => $tags
],
]
];
$data_post = json_encode($data);
$url = "$domain/ghost/api/v4/admin/posts/?source=html";
$headers = ['Content-Type: application/json'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_HTTPHEADER, $headers );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'ghost-cookie.txt' );
curl_setopt($ch, CURLOPT_COOKIEFILE, 'ghost-cookie.txt' );
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_post);
$result = curl_exec($ch);
$err = curl_error($ch);
curl_close($ch);
echo json_encode($result);
} else {
$msg['message'] = 'Oops! empty field detected. Please fill all the fields';
echo json_encode($msg);
}
} else {
$msg['message'] = 'Please fill all the fields';
echo json_encode($msg);
}