When importing a channel from another server, try to auto-discover the best available api path.

This commit is contained in:
zotlabs
2016-10-11 20:53:13 -07:00
parent 1a4a8f1ef7
commit f56b4773cb
2 changed files with 33 additions and 10 deletions

View File

@@ -2288,3 +2288,22 @@ function z_mail($params) {
logger('notification: z_mail returns ' . $res, LOGGER_DEBUG);
return $res;
}
// discover the best API path available for redmatrix/hubzilla servers
function probe_api_path($host) {
$schemes = ['https', 'http' ];
$paths = ['/api/z/1.0/version', '/api/red/version' ];
foreach($schemes as $scheme) {
foreach($paths as $path) {
$curpath = $scheme . '://' . $host . $path;
$x = z_fetch_url($curpath);
if($x['success'] && ! strlen($x['body'],'not implemented'))
return str_replace('version','',$curpath);
}
}
return '';
}