3 * This test class pretends to be an RSS aggregator. It logs notifications
10 * @author Zach Copley <zach@status.net>
11 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
12 * @link http://status.net/
14 * StatusNet - the distributed open-source microblogging tool
15 * Copyright (C) 2009, StatusNet, Inc.
17 * This program is free software: you can redistribute it and/or modify
18 * it under the terms of the GNU Affero General Public License as published by
19 * the Free Software Foundation, either version 3 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU Affero General Public License for more details.
27 * You should have received a copy of the GNU Affero General Public License
28 * along with this program. If not, see <http://www.gnu.org/licenses/>.
31 if (!defined('STATUSNET')) {
36 * Dummy aggregator that acts as a proper notification handler. It
37 * doesn't do anything but respond correctly when notified via
38 * REST. Mostly, this is just and action I used to develop the plugin
39 * and easily test things end-to-end. I'm leaving it in here as it
40 * may be useful for developing the plugin further.
44 * @author Zach Copley <zach@status.net>
45 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
46 * @link http://status.net/
48 class LoggingAggregatorAction extends Action
50 var $challenge = null;
56 * @param array $args Web and URL arguments
58 * @return boolean false if user doesn't exist
60 function prepare($args)
62 parent::prepare($args);
64 $this->url = $this->arg('url');
65 $this->challenge = $this->arg('challenge');
67 common_debug("args = " . var_export($this->args, true));
68 common_debug('url = ' . $this->url . ' challenge = ' . $this->challenge);
76 * @param array $args $_REQUEST data (unused)
80 function handle($args)
82 parent::handle($args);
84 if (empty($this->url)) {
85 $this->showError(_('A URL parameter is required.'));
89 if (!empty($this->challenge)) {
92 if ($_SERVER['REQUEST_METHOD'] != 'GET') {
93 $this->showError(_m('This resource requires an HTTP GET.'));
97 header('Content-Type: text/xml');
98 echo $this->challenge;
103 if ($_SERVER['REQUEST_METHOD'] != 'POST') {
104 $this->showError(_m('This resource requires an HTTP POST.'));
108 header('Content-Type: text/xml');
109 Echo "<notifyResult success='true' msg='Thanks for the update.' />\n";
112 $this->ip = $_SERVER['REMOTE_ADDR'];
114 common_log(LOG_INFO, 'RSSCloud Logging Aggregator - ' .
115 $this->ip . ' claims the feed at ' .
116 $this->url . ' has been updated.');
120 * Show an XML error when things go badly
122 * @param string $msg the error message
126 function showError($msg)
128 header('HTTP/1.1 400 Bad Request');
129 header('Content-Type: text/xml');
130 echo "<?xml version='1.0'?>\n";
131 echo "<notifyResult success='false' msg='$msg' />\n";