diff options
author | Mario Vavti <mario@mariovavti.com> | 2018-10-19 11:18:28 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2018-10-19 11:18:28 +0200 |
commit | fa9e9510e5d993d183feb942fe74be5fdd07f5cf (patch) | |
tree | 41fec09f527a9346e043b8099b458a97d81b03ed /Zotlabs/Lib/Zotfinger.php | |
parent | 32de123db0ac526795a237ff46885fe8a332cbc0 (diff) | |
parent | 06b3ad1071c755757555baf941e2c0f446f97b21 (diff) | |
download | volse-hubzilla-fa9e9510e5d993d183feb942fe74be5fdd07f5cf.tar.gz volse-hubzilla-fa9e9510e5d993d183feb942fe74be5fdd07f5cf.tar.bz2 volse-hubzilla-fa9e9510e5d993d183feb942fe74be5fdd07f5cf.zip |
Merge branch '3.8RC'3.8
Diffstat (limited to 'Zotlabs/Lib/Zotfinger.php')
-rw-r--r-- | Zotlabs/Lib/Zotfinger.php | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/Zotlabs/Lib/Zotfinger.php b/Zotlabs/Lib/Zotfinger.php new file mode 100644 index 000000000..537e440d4 --- /dev/null +++ b/Zotlabs/Lib/Zotfinger.php @@ -0,0 +1,50 @@ +<?php + +namespace Zotlabs\Lib; + +use Zotlabs\Web\HTTPSig; + +class Zotfinger { + + static function exec($resource,$channel = null) { + + if(! $resource) { + return false; + } + + if($channel) { + $headers = [ + 'Accept' => 'application/x-zot+json', + 'X-Zot-Token' => random_string(), + ]; + $h = HTTPSig::create_sig($headers,$channel['channel_prvkey'],channel_url($channel),false); + } + else { + $h = [ 'Accept: application/x-zot+json' ]; + } + + $result = []; + + + $redirects = 0; + $x = z_fetch_url($resource,false,$redirects, [ 'headers' => $h ] ); + + if($x['success']) { + + $result['signature'] = HTTPSig::verify($x); + + $result['data'] = json_decode($x['body'],true); + + if($result['data'] && is_array($result['data']) && array_key_exists('encrypted',$result['data']) && $result['data']['encrypted']) { + $result['data'] = json_decode(crypto_unencapsulate($result['data'],get_config('system','prvkey')),true); + } + + return $result; + } + + return false; + } + + + +}
\ No newline at end of file |