-
Notifications
You must be signed in to change notification settings - Fork 1
/
handle-reply.php
40 lines (29 loc) · 956 Bytes
/
handle-reply.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
<?php
try {
require_once('Sprinkles.php');
$sprink = new Sprinkles();
$topic_id = request_param('topic_id');
$reply_url = request_param('replies_url');
if (!($content = request_param('content'))) {
redirect('topic.php?blank_reply=1&id=' . urlencode($topic_id));
exit(0);
}
$params = array('reply[content]' => $content);
if ($parent_id = request_param('parent_id'))
$params['reply[parent_id]'] = $parent_id;
$creds = $sprink->current_user_session();
if (!$creds)
die("Not logged in! (FIXME)");
$req = $sprink->oauthed_request('POST', $reply_url, $creds, null, $params);
if (201 != ($responseCode = $req->getResponseCode())) {
die("API Error $responseCode replying to $topic_id.");
}
$topic_url = $topic_id;
invalidate_http_cache($topic_url);
redirect('topic.php?id=' . urlencode($topic_id));
exit(0);
} catch (Exception $e) {
error_log("Exception thrown while preparing page: " . $e->getMessage());
$smarty->display('error.t');
}
?>