-
Notifications
You must be signed in to change notification settings - Fork 0
/
xmlrpc.php
97 lines (69 loc) · 1.79 KB
/
xmlrpc.php
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
require_once('./IXR_Library.php');
function login($username, $password) {
// 登录
return array(
);
}
// 根据用户名密码获取站点信息
function getUsersBlogs($args) {
$username = $args[0];
$password = $args[1];
// $user = login( $username, $password );
$struct = array(
'isAdmin' => true,
'url' => 'https://xxx.com/',
'blogid' => '1',
'blogName' => 'test',
'xmlrpc' => 'https://xxx.com/xmlrpc.php',
);
return array( $struct );
}
// 上传文件接口
function uploadFile($args) {
$username = $args[1];
$password = $args[2];
$data = $args[3];
// $user = login( $username, $password );
$name = $data['name'];
$type = $data['type'];
$bits = $data['bits'];
$localFile = './upload/'. $name;
// 写入本地
file_put_contents($localFile, $bits);
$webUrl = '';
// $struct = array();
// $struct['id'] = 1;
// $struct['file'] = $localFile;
// $struct['url'] = $localFile;
return array(
'id' => 2,
'file' => 'file path',
'url' => 'file url'
);
}
// 创建新文章
function newPost($args) {
$username = $args[1];
$password = $args[2];
$content_struct = $args[3];
// $user = login( $username, $password );
return $post_id;
}
// 根据文章ID更新文章
function editPost($args) {
$username = $args[1];
$password = $args[2];
$post_id = (int) $args[3];
$content_struct = $args[4];
$user = login( $username, $password );
return $post_id;
}
// rpc映射
$api = array(
'wp.getUsersBlogs' => 'getUsersBlogs',
'wp.newPost' => 'newPost',
'wp.editPost' => 'editPost',
'wp.uploadFile' => 'uploadFile'
);
new IXR_Server($api);