accept syndicate-to as an array
This commit is contained in:
parent
875a9fd909
commit
21978c981e
1 changed files with 10 additions and 4 deletions
|
@ -142,15 +142,21 @@ function get_syndication_targets(&$user) {
|
||||||
|
|
||||||
$r = micropub_get($user->micropub_endpoint, array('q'=>'syndicate-to'), $user->micropub_access_token);
|
$r = micropub_get($user->micropub_endpoint, array('q'=>'syndicate-to'), $user->micropub_access_token);
|
||||||
if($r['data'] && array_key_exists('syndicate-to', $r['data'])) {
|
if($r['data'] && array_key_exists('syndicate-to', $r['data'])) {
|
||||||
|
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']);
|
$targetURLs = preg_split('/, ?/', $r['data']['syndicate-to']);
|
||||||
foreach($targetURLs as $t) {
|
} else {
|
||||||
|
$targetURLs = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($targetURLs as $t) {
|
||||||
// If the syndication target doesn't have a scheme, add http
|
// If the syndication target doesn't have a scheme, add http
|
||||||
if(!preg_match('/^http/', $t))
|
if(!preg_match('/^http/', $t))
|
||||||
$tmp = 'http://' . $t;
|
$t = 'http://' . $t;
|
||||||
|
|
||||||
// Parse the target expecting it to be a URL
|
// 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
|
// 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
|
// parse_url will parse strings like http://twitter into an array with a host of twitter, which is not resolvable
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue