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 PingbackAction 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();
37 $server = xmlrpc_server_create();
38 xmlrpc_server_register_method($server, 'pingback.ping', array($this, 'ping'));
39 echo xmlrpc_server_call_method($server, file_get_contents('php://input'), null, array('encoding' => 'utf-8'));
40 xmlrpc_server_destroy($server);
44 function ping($method, $parameters) {
45 list($source, $target) = $parameters;
49 'faultCode' => 0x0010,
50 'faultString' => '"source" is missing'
56 'faultCode' => 0x0020,
57 'faultString' => '"target" is missing'
61 $response = linkback_get_source($source, $target);
64 'faultCode' => 0x0011,
65 'faultString' => 'Source does not link to target'
69 $notice = linkback_get_target($target);
72 'faultCode' => 0x0021,
73 'faultString' => 'Target not found'
77 $url = linkback_save($source, $target, $response, $notice);
81 'faultString' => 'An error occured while saving.'
85 return array('Success');