diff options
author | Aaron Parecki <aaron@parecki.com> | 2015-01-16 22:53:58 -0800 |
---|---|---|
committer | Aaron Parecki <aaron@parecki.com> | 2015-01-16 22:53:58 -0800 |
commit | 21978c981ec2fc5c84041113510ebdd3e9a2d2fb (patch) | |
tree | 04f17a332ba669d9e0fe2159c1cc73972adfe2d5 | |
parent | 875a9fd90944eef8bf94f24594c80b9433ec824d (diff) |
accept syndicate-to as an array
-rw-r--r-- | lib/helpers.php | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/helpers.php b/lib/helpers.php index 9993231..6afa55c 100644 --- a/lib/helpers.php +++ b/lib/helpers.php @@ -142,15 +142,21 @@ function get_syndication_targets(&$user) { $r = micropub_get($user->micropub_endpoint, array('q'=>'syndicate-to'), $user->micropub_access_token); if($r['data'] && array_key_exists('syndicate-to', $r['data'])) { - $targetURLs = preg_split('/, ?/', $r['data']['syndicate-to']); - foreach($targetURLs as $t) { + if(is_array($r['data']['syndicate-to'])) { + $targetURLs = $r['data']['syndicate-to']; + } elseif(is_string($r['data']['syndicate-to'])) { + $targetURLs = preg_split('/, ?/', $r['data']['syndicate-to']); + } else { + $targetURLs = array(); + } + foreach($targetURLs as $t) { // If the syndication target doesn't have a scheme, add http if(!preg_match('/^http/', $t)) - $tmp = 'http://' . $t; + $t = 'http://' . $t; // Parse the target expecting it to be a URL - $url = parse_url($tmp); + $url = parse_url($t); // If there's a host, and the host contains a . then we can assume there's a favicon // parse_url will parse strings like http://twitter into an array with a host of twitter, which is not resolvable |