From ce5712435938cae8868c7dbeea01085a350a04d2 Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Tue, 28 Feb 2017 19:33:55 -0800 Subject: also support finding the repost URL from an h-cite --- controllers/controllers.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/controllers/controllers.php b/controllers/controllers.php index c780490..782a318 100644 --- a/controllers/controllers.php +++ b/controllers/controllers.php @@ -226,7 +226,21 @@ $app->get('/repost', function() use($app) { $edit_data = get_micropub_source($user, $params['edit'], 'repost-of'); $url = $params['edit']; if(isset($edit_data['repost-of'])) { - $repost_of = $edit_data['repost-of'][0]; + $repost = $edit_data['repost-of'][0]; + print_r($edit_data); + if(is_string($edit_data['repost-of'][0])) { + $repost_of = $repost; + } elseif(is_array($repost)) { + if(array_key_exists('type', $repost) && in_array('h-cite', $repost)) { + if(array_key_exists('url', $repost['properties'])) { + $repost_of = $repost['properties']['url'][0]; + } + } else { + // Error + } + } else { + // Error: don't know what type of post this is + } } } else { $edit_data = false; -- cgit v1.2.3