forked from richp10/discourse-api-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.php
49 lines (35 loc) · 1.04 KB
/
example.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
<?php
require_once 'lib/DiscourseAPI.php';
$api = new DiscourseAPI('apitest.discoursehosting.net', API_KEY, API_HOST_PROTOCOL);
// create user
$r = $api->createUser('John Doe', 'johndoe', '[email protected]', 'foobar!!');
print_r($r);
// in order to activate we need the id
$r = $api->getUserByUsername('johndoe');
print_r($r);
// activate the user
$r = $api->activateUser($r->apiresult->user->id);
print_r($r);
// create a category
$r = $api->createCategory('a new category', 'cc2222');
print_r($r);
$catId = $r->apiresult->category->id;
// create a topic
$r = $api->createTopic(
'This is the title of a brand new topic',
"This is the body text of a brand new topic. I really don't know what to say",
$catId,
'johndoe'
);
print_r($r);
$topicId = $r->apiresult->id;
$r = $api->createPost(
'This is the body of a new post in an existing topic',
$topicId,
$catId,
'johndoe'
);
// change sitesetting
// use 'true' and 'false' between quotes
$r = $api->changeSiteSetting('invite_expiry_days', 29);
print_r($r);