Simple latest comment list
[anoweco.git] / www / micropub.php
index 0dd476a17f877b41bc9975471addeb8d1f633f50..eff6ea7f26fde64042859ad3a79d36fa06e486fb 100644 (file)
@@ -83,8 +83,10 @@ function handleCreate($json, $token)
     }
 
     $storage = new Storage();
+    $lb      = new Linkback();
     try {
         $id = $storage->addComment($json, $userId);
+        $lb->ping($id);
 
         header('HTTP/1.0 201 Created');
         header('Location: ' . Urls::full(Urls::comment($id)));
@@ -163,7 +165,8 @@ if ($_SERVER['REQUEST_METHOD'] == 'GET') {
             'Content-Type header missing.'
         );
     }
-    $ctype = $_SERVER['CONTENT_TYPE'];
+    list($ctype) = explode(';', $_SERVER['CONTENT_TYPE'], 2);
+    $ctype = trim($ctype);
     if ($ctype == 'application/x-www-form-urlencoded') {
         if (!isset($_POST['action'])) {
             $_POST['action'] = 'create';
@@ -209,8 +212,8 @@ if ($_SERVER['REQUEST_METHOD'] == 'GET') {
         $json = $base;
         $json->properties = (object) $data;
         handleCreate($json, $token);
-    } else if ($ctype == 'application/javascript') {
-        $input = file_get_contents('php://stdin');
+    } else if ($ctype == 'application/json') {
+        $input = file_get_contents('php://input');
         $json  = json_decode($input);
         if ($json === null) {
             mpError(