-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit_post.php
79 lines (47 loc) · 1.51 KB
/
edit_post.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
$titles = array();
function getPages($rpcurl, $username, $password) {
global $titles;
$params = array(1, $username, $password);
$request = xmlrpc_encode_request('wp.getPageList', $params);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
curl_setopt($ch, CURLOPT_URL, $rpcurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
$results = curl_exec($ch);
curl_close($ch);
$response = xmlrpc_decode($results);
//var_dump($response);
foreach($response as $page) {
$titles[] = array(
'title'=>$page['page_title'],
'id'=>$page['page_id'],
'page_parent_id' => $page['page_parent_id']
);
}
}
getPages('http://dev-ppldev.pantheonsite.io/xmlrpc.php', 'jbent', 'Flight714!');
function editPage($page_title, $page_id, $rpcurl, $user, $pass) {
$content = array(
'title'=>$page_title,
'description'=>'AAGGGGGGGGGGGGGGGGGGGGGGGG'
);
$params = array(0, $page_id, $user, $pass, $content, true);
$request = xmlrpc_encode_request('wp.editPage', $params);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
curl_setopt($ch, CURLOPT_URL, $rpcurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
$results = curl_exec($ch);
curl_close($ch);
return $results;
var_dump($results);
}
$page_title = 'Test Page - PPL';
$page_id = '219';
$rpcurl = 'http://dev-ppldev.pantheonsite.io/xmlrpc.php';
$user = 'jbent';
$pass = 'Flight714!';
editPage($page_title, $page_id, $rpcurl, $user, $pass);
?>