From 592eac5d8dc4c704bfb34915c0703fc2aecc6d46 Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Sun, 6 Jul 2014 18:28:18 -0700 Subject: Adds support for querying your micropub endpoint to check for syndication targets. This changes the value of "in-reply-to" to use hyphens instead of underscore separators!! Also shows you the full request made to your micropub endpoint. --- controllers/controllers.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'controllers/controllers.php') diff --git a/controllers/controllers.php b/controllers/controllers.php index 5b28bb8..dc18584 100644 --- a/controllers/controllers.php +++ b/controllers/controllers.php @@ -32,6 +32,7 @@ $app->get('/new', function() use($app) { 'micropub_scope' => $user->micropub_scope, 'micropub_access_token' => $user->micropub_access_token, 'response_date' => $user->last_micropub_response_date, + 'syndication_targets' => json_decode($user->syndication_targets, true), 'test_response' => $test_response, 'location_enabled' => $user->location_enabled )); @@ -104,12 +105,28 @@ $app->get('/add-to-home', function() use($app) { } }); +$app->get('/micropub/syndications', function() use($app) { + if($user=require_login($app)) { + $data = get_syndication_targets($user); + $app->response()->body(json_encode(array( + 'targets' => $data['targets'], + 'response' => $data['response'] + ))); + } +}); + $app->post('/micropub/post', function() use($app) { if($user=require_login($app)) { $params = $app->request()->params(); + // Remove any blank params + $params = array_filter($params, function($v){ + return $v !== ''; + }); + // Now send to the micropub endpoint $r = micropub_post($user->micropub_endpoint, $params, $user->micropub_access_token); + $request = $r['request']; $response = $r['response']; $user->last_micropub_response = json_encode($r); @@ -126,6 +143,7 @@ $app->post('/micropub/post', function() use($app) { $user->save(); $app->response()->body(json_encode(array( + 'request' => htmlspecialchars($request), 'response' => htmlspecialchars($response), 'location' => $location, 'error' => $r['error'], -- cgit v1.2.3