diff options
author | Aaron Parecki <aaron@parecki.com> | 2015-01-23 12:40:19 -0800 |
---|---|---|
committer | Aaron Parecki <aaron@parecki.com> | 2015-01-23 12:40:19 -0800 |
commit | 1c4bf54da4ca2419598a8cb541b3cb3737452aab (patch) | |
tree | 45bb795a2d9f63964202c188eaca6ea7565775be /lib/helpers.php | |
parent | 9fe3a8ff07733145847c84b27c983fb7986d6e70 (diff) |
use php arrays for syndicate-to properties
Diffstat (limited to 'lib/helpers.php')
-rw-r--r-- | lib/helpers.php | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/helpers.php b/lib/helpers.php index 6afa55c..6bbe327 100644 --- a/lib/helpers.php +++ b/lib/helpers.php @@ -100,6 +100,7 @@ function micropub_post($endpoint, $params, $access_token) { $post = http_build_query(array_merge(array( 'h' => 'entry' ), $params)); + $post = preg_replace('/%5B[0-9]+%5D/', '%5B%5D', $post); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, true); @@ -145,6 +146,7 @@ function get_syndication_targets(&$user) { if(is_array($r['data']['syndicate-to'])) { $targetURLs = $r['data']['syndicate-to']; } elseif(is_string($r['data']['syndicate-to'])) { + // support comma separated as a fallback $targetURLs = preg_split('/, ?/', $r['data']['syndicate-to']); } else { $targetURLs = array(); @@ -153,10 +155,12 @@ function get_syndication_targets(&$user) { foreach($targetURLs as $t) { // If the syndication target doesn't have a scheme, add http if(!preg_match('/^http/', $t)) - $t = 'http://' . $t; + $t2 = 'http://' . $t; + else + $t2 = $t; // Parse the target expecting it to be a URL - $url = parse_url($t); + $url = parse_url($t2); // 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 |