From f56b4773cbb84950cd9ff07f920dd738c3ea5dbc Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 11 Oct 2016 20:53:13 -0700 Subject: When importing a channel from another server, try to auto-discover the best available api path. --- include/network.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'include/network.php') diff --git a/include/network.php b/include/network.php index 7851f8976..97dca2b1a 100644 --- a/include/network.php +++ b/include/network.php @@ -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 ''; +} \ No newline at end of file -- cgit v1.2.3