3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU Affero General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Affero General Public License for more details.
13 * You should have received a copy of the GNU Affero General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 if (!defined('STATUSNET')) {
21 class WebmentionAction extends Action
23 protected function handle()
25 GNUsocial::setApi(true); // Minimize error messages to aid in debugging
27 if ($this->isPost()) {
28 return $this->handlePost();
36 $source = $this->arg('source');
37 $target = $this->arg('target');
39 header('Content-Type: text/plain; charset=utf-8');
42 echo _m('"source" is missing')."\n";
43 throw new ServerException(_m('"source" is missing'), 400);
47 echo _m('"target" is missing')."\n";
48 throw new ServerException(_m('"target" is missing'), 400);
51 $response = linkback_get_source($source, $target);
53 echo _m('Source does not link to target.')."\n";
54 throw new ServerException(_m('Source does not link to target.'), 400);
57 $notice = linkback_get_target($target);
59 echo _m('Target not found')."\n";
60 throw new ServerException(_m('Target not found'), 404);
63 $url = linkback_save($source, $target, $response, $notice);
65 echo _m('An error occured while saving.')."\n";
66 throw new ServerException(_m('An error occured while saving.'), 500);