Example #1
0
 function handlePost()
 {
     $source = $this->arg('source');
     $target = $this->arg('target');
     header('Content-Type: text/plain; charset=utf-8');
     if (!$source) {
         echo _m('"source" is missing') . "\n";
         throw new ServerException(_m('"source" is missing'), 400);
     }
     if (!$target) {
         echo _m('"target" is missing') . "\n";
         throw new ServerException(_m('"target" is missing'), 400);
     }
     $response = linkback_get_source($source, $target);
     if (!$response) {
         echo _m('Source does not link to target.') . "\n";
         throw new ServerException(_m('Source does not link to target.'), 400);
     }
     $notice = linkback_get_target($target);
     if (!$notice) {
         echo _m('Target not found') . "\n";
         throw new ServerException(_m('Target not found'), 404);
     }
     $url = linkback_save($source, $target, $response, $notice);
     if (!$url) {
         echo _m('An error occured while saving.') . "\n";
         throw new ServerException(_m('An error occured while saving.'), 500);
     }
     echo $url . "\n";
     return true;
 }
Example #2
0
 function ping($method, $parameters)
 {
     list($source, $target) = $parameters;
     if (!$source) {
         return array('faultCode' => 0x10, 'faultString' => '"source" is missing');
     }
     if (!$target) {
         return array('faultCode' => 0x20, 'faultString' => '"target" is missing');
     }
     $response = linkback_get_source($source, $target);
     if (!$response) {
         return array('faultCode' => 0x11, 'faultString' => 'Source does not link to target');
     }
     $notice = linkback_get_target($target);
     if (!$notice) {
         return array('faultCode' => 0x21, 'faultString' => 'Target not found');
     }
     $url = linkback_save($source, $target, $response, $notice);
     if (!$url) {
         return array('faultCode' => 0, 'faultString' => 'An error occured while saving.');
     }
     return array('Success');
 }