diff options
author | Aaron Parecki <aaron@parecki.com> | 2014-07-06 18:28:18 -0700 |
---|---|---|
committer | Aaron Parecki <aaron@parecki.com> | 2014-07-06 18:28:18 -0700 |
commit | 592eac5d8dc4c704bfb34915c0703fc2aecc6d46 (patch) | |
tree | a9875ed88b33674da0571c0ad8007c01eda07f23 /controllers/controllers.php | |
parent | b2337158a38b7dfda6d5c4e3c5f0dd4ae9f4845d (diff) |
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.
Diffstat (limited to 'controllers/controllers.php')
-rw-r--r-- | controllers/controllers.php | 18 |
1 files changed, 18 insertions, 0 deletions
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'], |