5 * List syndication targets
7 * @author Christian Weiske <cweiske@cweiske.de>
8 * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
9 * @link http://cweiske.de/shpub.htm
13 public function __construct(Config $cfg)
18 public static function opts(\Console_CommandLine $optParser)
20 $cmd = $optParser->addCommand('targets');
21 $cmd->description = 'List a server\'s syndication targets';
24 public function run(\Console_CommandLine_Result $cmdRes)
26 $req = new Request($this->cfg->host, $this->cfg);
27 $req->req->setMethod('GET');
28 $req->req->setHeader('Content-type');
29 $req->req->getUrl()->setQueryVariable('q', 'syndicate-to');
32 if ($res->getHeader('content-type') != 'application/json') {
33 Log::err('response data are not of type application/json');
37 $data = json_decode($res->getBody(), true);
38 if (!isset($data['syndicate-to'])) {
39 Log::err('"syndicate-to" property missing');
43 foreach ($data['syndicate-to'] as $target) {
44 Log::msg($target['name']);
45 Log::msg(' ' . $target['uid']);
46 if (isset($target['user'])) {
47 Log::msg(' User: ' . $target['user']['name']);
49 if (isset($target['service'])) {
50 Log::msg(' Service: ' . $target['service']['name']);