-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit.php
36 lines (31 loc) · 916 Bytes
/
edit.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
<?php
$client = require_once __DIR__ . '/../oauth.php';
use MediaWiki\OAuthClient\Client;
use MediaWiki\OAuthClient\ClientConfig;
use MediaWiki\OAuthClient\Consumer;
use MediaWiki\OAuthClient\Token;
$apiUrl = 'https://' . $_POST['site'] . '.wikipedia.org/w/api.php';
session_start();
$accessToken = new Token( $_SESSION['access_key'], $_SESSION['access_secret'] );
$editToken = json_decode( $client->makeOAuthCall(
$accessToken,
$apiUrl . "?action=query&meta=tokens&format=json"
))->query->tokens->csrftoken;
$ident = $client->identify( $accessToken );
$apiParams = [
'action' => 'edit',
'title' => $_POST['title'],
'section' => '0',
'summary' => $_POST['summary'],
'text' => $_POST['text'],
'token' => $editToken,
'format' => 'json',
];
$editResult = json_decode( $client->makeOAuthCall(
$accessToken,
$apiUrl,
true,
$apiParams
) );
print_r( $editResult );
?>