3 * StatusNet, the distributed open-source microblogging tool
5 * Show a notice's attachment
9 * LICENCE: This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * @author Hannes Mannerheim <h@nnesmannerhe.im>
25 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
26 * @link http://www.gnu.org/software/social/
29 if (!defined('GNUSOCIAL')) { exit(1); }
32 * Check if a url have a push-hub, i.e. if it is possible to subscribe
35 class ApiCheckHubAction extends ApiAuthAction
37 protected $url = null;
40 * Take arguments for running
42 * @param array $args $_REQUEST args
44 * @return boolean success flag
46 protected function prepare(array $args=array())
48 parent::prepare($args);
50 if ($this->format !== 'json') {
51 $this->clientError('This method currently only serves JSON.', 415);
54 $this->url = urldecode($args['url']);
56 if (empty($this->url)) {
57 $this->clientError(_('No URL.'), 403);
60 if (!common_valid_http_url($this->url)) {
61 $this->clientError(_('Invalid URL.'), 403);
70 * @param array $args $_REQUEST data (unused)
74 protected function handle()
78 $discover = new FeedDiscovery();
81 $feeduri = $discover->discoverFromURL($this->url);
83 $huburi = $discover->getHubLink();
85 } catch (FeedSubNoFeedException $e) {
86 $this->clientError(_('No feed found'), 403);
87 } catch (FeedSubBadResponseException $e) {
88 $this->clientError(_('No hub found'), 403);
91 $hub_status = array();
93 $hub_status = array('huburi' => $huburi);
96 $this->initDocument('json');
97 $this->showJsonObjects($hub_status);
98 $this->endDocument('json');
102 * Return true if read only.
106 * @param array $args other arguments
108 * @return boolean is read only action?
111 function isReadOnly(array $args=array())