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
51 var $challenge = null;
57 * @param array $args Web and URL arguments
59 * @return boolean false if user doesn't exist
62 function prepare($args)
64 parent::prepare($args);
66 $this->url = $this->arg('url');
67 $this->challenge = $this->arg('challenge');
69 common_debug("args = " . var_export($this->args, true));
70 common_debug('url = ' . $this->url . ' challenge = ' . $this->challenge);
78 * @param array $args $_REQUEST data (unused)
83 function handle($args)
85 parent::handle($args);
87 if (empty($this->url)) {
88 $this->showError('Hey, you have to provide a url parameter.');
92 if (!empty($this->challenge)) {
96 if ($_SERVER['REQUEST_METHOD'] != 'GET') {
97 $this->showError('This resource requires an HTTP GET.');
101 header('Content-Type: text/xml');
102 echo $this->challenge;
108 if ($_SERVER['REQUEST_METHOD'] != 'POST') {
109 $this->showError('This resource requires an HTTP POST.');
113 header('Content-Type: text/xml');
114 Echo "<notifyResult success='true' msg='Thanks for the update.' />\n";
117 $this->ip = $_SERVER['REMOTE_ADDR'];
119 common_log(LOG_INFO, 'RSSCloud Logging Aggregator - ' .
120 $this->ip . ' claims the feed at ' .
121 $this->url . ' has been updated.');
125 * Show an XML error when things go badly
127 * @param string $msg the error message
132 function showError($msg)
134 header('HTTP/1.1 400 Bad Request');
135 header('Content-Type: text/xml');
136 echo "<?xml version='1.0'?>\n";
137 echo "<notifyResult success='false' msg='$msg' />\n";