Create XML output for RSD with XML::fromArray()
authorPhilipp Holzer <admin@philipp.info>
Sun, 5 May 2019 16:15:39 +0000 (18:15 +0200)
committerPhilipp Holzer <admin@philipp.info>
Sun, 5 May 2019 16:15:39 +0000 (18:15 +0200)
src/Module/ReallySimpleDiscovery.php
view/templates/rsd.tpl [deleted file]

index 4c14d3c..515285d 100644 (file)
@@ -3,7 +3,7 @@
 namespace Friendica\Module;
 
 use Friendica\BaseModule;
-use Friendica\Core\Renderer;
+use Friendica\Util\XML;
 
 /**
  * Prints the rsd.xml
@@ -13,9 +13,43 @@ class ReallySimpleDiscovery extends BaseModule
 {
        public static function rawContent()
        {
-               header ('Content-Type: text/xml');
-               $tpl = Renderer::getMarkupTemplate('rsd.tpl');
-               echo Renderer::replaceMacros($tpl);
+               header('Content-Type: text/xml');
+
+               $app = self::getApp();
+               $xml = null;
+               echo XML::fromArray([
+                       'rsd' => [
+                               '@attributes' => [
+                                       'version' => '1.0',
+                                       'xmlns'   => 'http://archipelago.phrasewise.com/rsd',
+                               ],
+                               'service'     => [
+                                       'engineName' => 'Friendica',
+                                       'engineLink' => 'http://friendica.com',
+                                       'apis'       => [
+                                               'api' => [
+                                                       '@attributes' => [
+                                                               'name'      => 'Twitter',
+                                                               'preferred' => 'true',
+                                                               'apiLink'   => $app->getBaseURL(),
+                                                               'blogID'    => '',
+                                                       ],
+                                                       'settings'    => [
+                                                               'docs'    => [
+                                                                       'http://status.net/wiki/TwitterCompatibleAPI',
+                                                               ],
+                                                               'setting' => [
+                                                                       '@attributes' => [
+                                                                               'name' => 'OAuth',
+                                                                       ],
+                                                                       'false',
+                                                               ],
+                                                       ],
+                                               ]
+                                       ],
+                               ],
+                       ],
+               ], $xml);
                exit();
        }
 }
diff --git a/view/templates/rsd.tpl b/view/templates/rsd.tpl
deleted file mode 100644 (file)
index c194e8f..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<rsd version="1.0" xmlns="http://archipelago.phrasewise.com/rsd">
-       <service>
-               <engineName>Friendica</engineName>
-               <engineLink>http://friendica.com/</engineLink>
-               <apis>
-                       <api name="Twitter" preferred="true" apiLink="{{$baseurl}}/api/" blogID="">
-                               <settings>
-                                       <docs>http://status.net/wiki/TwitterCompatibleAPI</docs>
-                                       <setting name="OAuth">false</setting>
-                               </settings>
-                       </api>
-               </apis>
-       </service>
-</rsd>