diff options
author | Aaron Parecki <aaron@parecki.com> | 2017-10-29 15:32:45 -0700 |
---|---|---|
committer | Aaron Parecki <aaron@parecki.com> | 2017-10-29 15:32:45 -0700 |
commit | 97ba7d0347faa84a017cacb069e7ab45fd16c8dd (patch) | |
tree | 200e3c471b65e189f3e09b6c525412c1b90de14d /controllers/controllers.php | |
parent | ffb3011eeb8620fde05c7893d2fe98d3d1ae0bb3 (diff) |
query the media endpoint for the last photo uploaded
Diffstat (limited to 'controllers/controllers.php')
-rw-r--r-- | controllers/controllers.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/controllers/controllers.php b/controllers/controllers.php index b028193..b263164 100644 --- a/controllers/controllers.php +++ b/controllers/controllers.php @@ -90,6 +90,25 @@ $app->get('/new', function() use($app) { } }); +$app->get('/new/last-photo.json', function() use($app) { + if($user=require_login($app)) { + $url = null; + + if($user->micropub_media_endpoint) { + // Request the last file uploaded from the media endpoint + $response = micropub_get($user->micropub_media_endpoint, ['q'=>'last'], $user->micropub_access_token); + if(isset($response['data']['url'])) { + $url = $response['data']['url']; + } + } + + $app->response()['Content-type'] = 'application/json'; + $app->response()->body(json_encode(array( + 'url' => $url + ))); + } +}); + $app->get('/bookmark', function() use($app) { if($user=require_login($app)) { $params = $app->request()->params(); |